Working with Laravel 5.5 I have a problem with the variable "id" when placing the AJAX route. I happened to show you
Route
Route::DELETE('deletePlan/{id}', 'FormDController@deletePlan')->name('d.deletePlan');
In the AJAX I have the following (I clarify that the value of the "id" to the AJAX arrives well, the error arises when I add it to the route
$('.delete_plan').on('click', function(e) {
e.preventDefault();
var row = $(this).parents(".contenedor");
var li = e.target.parentNode;
var id= li.id;
var param = {
'id' : id,
'_method' : 'delete',
'_token' : '{{Session::token()}}'
};
ruta1 = "http://192.168.156.201/EMPRESA/intranet/administrator/d/deletePlan/" + id;
$.ajax({
url: ruta1,
type : 'post',
data : param,
success: function( msg ) {
row.fadeOut();
alert("Registro borrado correctamente !!!");
},
error: function( data ) {
alert("Ocurrió un error !!!");
}
});
return false;
});
As it is route1 it works well, obviously I put it to test only, this means that the rest is all good, and in the controller is also all good. Now instead of that url probe in different ways put the "router" as it should, and in some cases it pulls me that does not know id, in other cases it happens to the controller the WORD id and not its value, etc. I could not find the way to put the "route" accordingly.
"{{ route('d.deletePlan', "id") }}";
"{{ route('d.deletePlan', 'id') }}";
"{{ route('discapacidad.deletePlan') }}", + id;
None of these forms works for me, they all put the corresponding url but the variable in the first case and in the second one it puts the word "id" instead of taking the corresponding number. And in the last option I get an error saying that the parameter is missing
Could you help me how the route is placed? Also try to put single quotes on the outside instead of double quotes. I have tried several options but I could not make it work
I reiterate, the route or the URL places it well, the theme is the parameter, I can not form the url, for example
"http://192.168.156.201/EMPRESA/intranet/administrator/d/deletePlan/5";