This is a User delete example :
$(".userBtn").click(function(){
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax(
{
url: "user/delete/"+id,
type: 'delete', // replaced from put
dataType: "JSON",
data: {
"id": id // method and token not needed in data
},
success: function (response)
{
console.log(response); // see the reponse sent
},
error: function(xhr) {
console.log(xhr.responseText); // this line will save you tons of hours while debugging
// do something here because of error
}
});
});