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

220
Views
$.ajax an't figure out why PHP not receiving POST data from $.ajax call

$.ajax successed,but in the php, I cannot get the data from ajax.

Notice: Undefined index: email in..

Notice: Undefined index: pass in ..

$(document).ready(function(){
 $(document).on('click',"#bolero-user-login",function(){
     var email = $("#edit-name").val();
     var pass  = $("#edit-pass").val();
     // alert (email);
     $.ajax({
        url:"functions/php/login.php",
        type:"POST",
        data:{ "email":email,"pass":pass},
        beforeSend: function () {
          
        },
        success:function(){
            alert("success");
            alert(email);
            $("#edit-name").val(" ");
            $("#edit-pass").val(" ");
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
             alert(XMLHttpRequest.status);
             alert(XMLHttpRequest.readyState);
             alert(textStatus);
        },
     });
     return false;
 });

});

PHP:

<?php

define ("root",$_SERVER['DOCUMENT_ROOT']);
// echo root;
include root.'/maroon5/includes/dbh.php';
print_r($_REQUEST);

$email = $_POST['email'];
$pwd = $_POST['pass'];

?>

HERE is the pictures from firefox

Image

Image

ajax success picture PHP console picture

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Change AJAX success into

success:function(data){             
    console.log(data);
    $("#edit-name").val(" ");
    $("#edit-pass").val(" ");
},

And AJAX page as well

<?php

define ("root",$_SERVER['DOCUMENT_ROOT']);
// echo root;
include root.'/maroon5/includes/dbh.php';
// print_r($_REQUEST);

$returnArr['email'] = $email;
$returnArr['pwd'] = $pwd;

echo  json_encode($returnArr);

?>
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!