title: Assigning a Boolean value to a variable after using $.ajax()
body: <p>I have written this Javascript code to validate my email address on a signup form; but after using $.ajax(), the returned value of the function is not correct (I suppose the returned value equal to 'false' but it would be 'true' if ajax success routine is executed)!! Can you give me a hand, please?</p>
  
  <pre><code>function validate_email(valID,displayID)
  {
  var email_format = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  var email = valID.val();
  var return_status = true;
  
  if(email == "")
  {
          displayID.append('\u26A0'+' ');
          displayID.append('msg1');
          return_status = false;
  } 
  else if(!email_format.test(email))
  {
          displayID.append('\u26A0'+' ');
          displayID.append('msg2');
          return_status = false;
  }
  else
  {
      //Checks for email uniquness in the DB
      var str_temp=valID.val().toLowerCase();
      var data="email="+str_temp.trim();
  
      $.ajax({                                      
          type: "POST",
          url: 'php_routines/ajax_email_validator.php',   
          data: data,                  
          success: function(results)          
          {
              if (results==1)
              {
                  displayID.append('\u26A0');
                  displayID.append('msg3');
                  return_status = false;                          
              }
          }
      });
  }
  return return_status;   
  </code></pre>
  
  <p>}</p>