I'm trying to generate a path in an Ajax request, but I get the following error:
Error: The route "profesor_edit" requires the parameter "id".
The code is as follows:
$.ajax({
type: 'POST',
url: Routing.generate('verify_user'),
data: {name:name},
dataType: 'json',
success: function(response) {
if(response.data!=null){
$("#container").load(Routing.generate('user_edit'), { id: response.data }); //"response.data" contains the value returned by the ajax call is an id value
}
else{
$("#container").append("<span >It could not find the id</span>");
}
}
})
routing file:
user_edit:
path: /{id}/edit
defaults: { _controller: "BackendBundle:User:edit" }
I think I will be sending the wrong parameter, but it's the only way I've ever seen. I appreciate your help.
Routing.generate('user_edit', resonse.data)dokuTypeError: invalid 'in' operand e. Would you know why that is?response.dataexactly? it must be the user id.return new JsonResponse(array('data' =>$user->getId()), 200);