Im having problems with sending an ajax request using laravel 5.
This is what kicks of the ajax request when clicked.
<td>
<i data-service="{{$performer['serviceID']}}" class="fa fa-eye"></i>{{$performer['name'] }}
</td>
Ajax code
$(function() {
$('.fa-eye').click(function () {
var service = $(this).attr('data-service');
jQuery.ajax({
crossDomain: true,
url: "/addWatchList",
beforeSend: function (xhr) {
var token = $('meta[name="csrf_token"]').attr('content');
console.log(token);
if (token) {
return xhr.setRequestHeader('X-CSRF-TOKEN', token);
}
},
type: "POST",
dataType: "json",
processdata: true,
data: {
service: service
},
success: function( data ) {
alert(data);
},
error: function (error) {
console.log(error);
//alert("xhr=" + xhr + " b=" + b + " c=" + c);
}
});
alert('went past ajax');
});
});
Now my ajax request isn't even reaching my controller.
The error i get is xhr=[object Object] b=parsererror c=SyntaxError: Unexpected token <
Does anyone know why this is happening?