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

115
Views
XMLHttpRequest obtiene la URL pero no puede redirigir

Estoy haciendo que un formulario de inicio de sesión sea verdadero como XMLHttpRequest. Cuando un usuario ingresa detalles incorrectos , aparecerá un mensaje con un error. Pero cuando un usuario ingresa los detalles correctos , debe ir a una nueva página (panel).

Esta es una parte de mi PHP

 <?PHP // Details are correct $output = header('Location:dashboard/index.php'); // Details are incorrect $output = '<h6 class="omessagetext" id="error" style="color: #f05461">Incorrect e-mail or password</h6>'; ?>

este es mi javascript

 var data = new FormData(); data.append("email", document.getElementById("inputmail").value); data.append("password", document.getElementById("inputpassword").value); var xhr = new XMLHttpRequest(); xhr.open("POST", "login.php"); xhr.onload = function() { if (xhr.readyState == 4 && xhr.status == 200) { var responsetext = xhr.responseText; if (responsetext.location){ window.location.href = responsetext.location }else { document.getElementById('errordiv').innerHTML = responsetext; } } }; xhr.send(data); return false;

He buscado mucho pero no encuentro la respuesta. ¡Espero que puedas ayudarme!

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