Yes.
If you have a route like
Route::post('some-endpoint', 'SomeMethod@SomeController');
Then your ajax would just be
$.ajax({
url: '/some-endpoint',
method: 'post',
dataType: 'json',
data: {
someKey: someValue,
anotherKey: anotheValue
},
success: function(data) {
// do something with data returned
},
error: function(data) {
// handle error
}
});
For all POST/PUT/PATCH/DELETE routes, you will need to add the csrf token (like you do for all forms). It's best to do this globally so all ajax calls will use it and you don't have to set it each time.
So in your main blade template, you'd just create a meta tag
<meta name="csrf-token" content="{{ csrf_token() }}">
And then use jquery's $.ajaxSetup() to set it for all ajax requests.
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
https://laravel.com/docs/5.6/csrf#csrf-x-csrf-token