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

144
Views
Cómo escuchar la respuesta del servidor 302

Estoy tratando de lograr lo siguiente. Después de enviar un formulario con éxito, quiero ejecutar un código después de que la respuesta del servidor sea 302. Para este ejemplo, tengo un formulario que está esperando para ser enviado, después de un envío exitoso, el servidor devuelve una respuesta 302. Estoy tratando de escuchar esta respuesta para poder ejecutar un fragmento de código después de la respuesta 302. Esto es lo que he hecho hasta ahora:

 var posts = new XMLHttpRequest(); posts.onreadystatechange = function() { if (posts.status == 302) { alert("succesfull") } } posts.open("POST", "http://127.0.0.1:8000/", true); posts.send();

Esto no funciona, ¿alguien puede explicar por qué?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

le falta readyState en la condición if que contiene el estado de XMLHttpRequest.

intente modificar su código como a continuación: -

 function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { alert('passed!') } }; xhttp.open("POST", "http://127.0.0.1:8000/", true); xhttp.send(); }

readyState 4 significa que la solicitud finalizó y la respuesta está lista.

about 4 years ago · Juan Pablo Isaza 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!