console log the token, I cant see how you've defined the data to the element...
If you've only got one form element on the page try
var token = $('[name="_token"]').val();
Yeah sorry i forgot to mention.
I'm using
data-token="{{ csrf_token() }}
from the input field, and doing
alert(token);
returns the key. Thats why i find it so strange.
I added the token to my header like it suggests in the documentation.
<meta name="csrf-token" content="{{ csrf_token() }}" />
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community