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

163
Views
¿Por qué obtengo una matriz para $_POST['variable'] de un envío de formulario de inicio de sesión de AJAX?

Estoy aprendiendo AJAX siguiendo los tutoriales en https://www.w3schools.com/xml/ajax_intro.asp . He completado con éxito un par de solicitudes GET, ahora estoy intentando una solicitud POST.

mi formulario:

 <input class="form-control" type="email" id="log_email" required name="log_email"> <input class="form-control" type="password" id="log_password" required name="log_password"> <a class="btn" onclick="login(this)" >Log in</a>

Mi Ajax:

 <script type="text/javascript"> function login(this_record) { var xhttp = new XMLHttpRequest(); var UsrEml = $('#log_email').val(); var UsrPw = $("#log_password").val(); var AjaxURL = ("ajax_login.php") ; var AjaxPost = ("eml=" + UsrEml + "&pw=" + UsrPw); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("accountstuff").innerHTML = this.responseText; } }; xhttp.open("POST", AjaxURL, true); xhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhttp.send(AjaxPost); } </script>

Mi PHP:

 <?php echo ($_POST["eml"]) ; ?>

El resultado es: Array ( [eml] => test@user.com [pw] => Password1 )

Estaba esperando: test@user.com

¿Por qué obtengo una matriz para una variable $_POST?

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!