Hello community, I'm still very new to ajax, and have once been able to make an ajax request with jQuery and the wordpress framework. (even though I didn't completely comprehend what was happening...).
Does anyone know any guide on how to use ajax with laravel?
Cheers!
You Simply Refers To jQuery Api For Ajax Request And Then Just Put In The Url Property To Either url('/') to That Route or action ('thisController@this'). That is All and then return json response. success will handle that. Pretty Simple.
var url = 'YOUR URL HERE';
$.ajax({
url: url,
type: 'POST',
headers: {
'X-CSRF-Token': $('meta[name=_token]').attr('content')
},
data: {
// Any data you want to post here
'name' => 'some name',
'age' => 18
}
}).done(function () {
// Do something when posting is done
});
Note that the headers file will retrieve the access token. You need to place this in the head of your html structure ;)