Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
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:

...
XHR.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
XHR.setRequestHeader("X-CSRFToken", FD.get("_token"));
...

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.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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

XHR.setRequestHeader("X-Requested-With", 'XMLHttpRequest');
XHR.setRequestHeader("Content-type", 'multipart/form-data'); // or application/json
XHR.setRequestHeader("X-CSRF-Token", FD.get("_token"));
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!