try returning token as _token in data rather than as header
it worked for me http://novate.co.uk/laravel-5-csrf-tokens-in-ajax-calls/ :-)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
When i make ajax call like this:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
method : 'POST',
url : '/article',
data: {'content' : 'text'},
}).done(function (data) {
callback(data)
}).fail(function () {
alert('Error');
});
When it check csrf token, it allways return false in file /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php line 67 (from function tokensMatch() line107)
And this ONLY on internet explorer... I try to send it via data, get token from {{csrf-field}},etc... Nothing better.
An idea ?
Please or to participate in this conversation.