Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda