阿贾克斯。 从查询中检索信息

I am really confused at the moment, I am very new to all this just being learning java script and php . I am trying to use ajax to check the db to see if the email exist and then if it is cancel the submit of the form. I cant seem to retrieve the information from the XML. I am probably doing it completely wrong, but that why I am asking here , to lean

So if you could help would be great

JAVA SCRIPT

//validate the sign up/regiser form
function validateForm() {

  //Get password varibles 
  var pass = document.forms["signup"]["sign-up-password"].value;
  var confPass = document.forms["signup"]["password-confirm"].value;

  //Check if they match
  if (pass != confPass) {
      alert("Password does not match");
      return false;
  }

  //Ajax functions 
  if(xmlHttp.readyState==0 || xmlHttp.readyState==4){

    alert("im here");

    email = document.getElementById('email2').value;
    xmlHttp.open("GET", "php/ajaxCom.php?email=" + email, true);
    xmlHttp.onreadystatechange = handleServerResponse;

    xmlHttp.send(null);

  }else{
    setTimeout('process()',1000);
  }

}

function handleServerResponse(){
  if(xmlHttp.readyState==4){
    var check=xmlHttp.status;
    if(xmlHttp.status==200){
      alert("also here 2");
      xmlResponse = xmlHttp.responseXML;
      xmlDocumentElement = xmlResponse.documentElement;
      message = xmlDocumentElement.firstChild.data;

      alert(message);
      return message;
    }
  }
}

php/xml

<?php
    $status;
    
if (isset($_GET['email'])) {
    $email_in_use = $_GET['email'];

    $query = mysqli_query($link, "SELECT * FROM users WHERE email='".$email_in_use."'");

    if(mysqli_num_rows($query) > 0){

        $status = false;
    }else{
        if( !mysqli_query( $link, $query ) )
        { $status = mysqli_error( $link ); }
        else
        { $status = true; }
    }

    $xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8" standalone="yes" ?><response><status/></response>');
    $xml->response->status = $status;
    echo $xml->asXML();
    echo $status;
}
?>

</div>

You are building and handling ajax XMLHttpRequest in an incorrect way.
Also, to be able to receive an XML response - set additional request header(will be shown further).
Change you ajax request as shown below:

   var xmlHttp = null; // this variable should be global to access from different functions
   ...
   //Ajax functions 

    email = document.getElementById('email2').value;

    xmlHttp = new XMLHttpRequest();    
    xmlHttp.open("GET", "php/ajaxCom.php?email=" + email, true);
    xmlHttp.setRequestHeader("Accept", "text/xml");
    xmlHttp.onreadystatechange = handleServerResponse;
    xmlHttp.send(null);
...

function handleServerResponse(){  
  if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
      var check=xmlHttp.status;
      var xmlResponse = xmlHttp.responseXML;
      var xmlDocumentElement = xmlResponse.documentElement;
      message = xmlDocumentElement.firstChild.data;
      alert(message);
      return message;
  } else{
    setTimeout('process()',1000);
  }
}