Skip to content
Advertisement

XMLHttpRequest not sending token (Laravel page expired)

I’m using Laravel and trying to send a form via XMLHttpRequest. It works but the request in the controller doesn’t identify it as ajax. The form has a csrf input.

I’ve tried several things, right now my code looks like:

JavaScript

But Laravel keeps sending a 419 | Page Expired response.

Maybe I’m misinterpreting this information, barking at the wrong tree, or I’m missing something here.

Advertisement

Answer

Try to add X-Requested-With header to your request and change your content header to multipart or json :

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement