Got the following code:
$('#next_btn').click(function() {
  addUser();
}); //$('#next_btn').click
function addUser() {
  var participant = {};
  var PID = 0;
  PID = FindUserByEmail($('#UserEmail').val());
  // do other things and add this user's data to the participant JSON object
} // function addUser()
function FindUserByEmail(user_email) {
  var url = escape(AJAX_URL_SELECTBYEMAIL + user_email);
  $.ajax({async: true
        , type:'POST'
        , url: url
        , dataType: 'json'
        , success: ajax_find_user_result 
        , error: ajax_error   
        }); // $.ajax
} // function FindUserByEmail(user_email)
function ajax_error(jqXHR, textStatus, errorThrown) {
  alert('X:' + jqXHR.status);
  alert('E:' + thrownError);
} // function ajax_error(jqXHR, textStatus, errorThrown)
function ajax_find_user_result(data) {
  if(data.result) {
    pid = data.result.PID;
    if (pid == 0) {
      alert('User not found');
      return false;
    } else {
      alert(pid);
    } // if (pid == 0)
  } else {
    alert('No results returned');
    return false;
  } // if(data.result)
} // function ajax_find_user_result(data)
The addUser() function is called from the click event. How can I make sure that the function FindUserByEmail returns the value from the ajax call? I am not sure how to do this.
Calling the URL by itself returns correct JSON and a demo returns the correct PID. Just not sure how to do it like above.
 
     
     
    