AJAX(), returning bool value out of success
I have a function to check my db for existing email addresses. I'm having problems trying to figure out how to get a boolean value out of the success function. I know that "exist" is out of scope, so that value can never be true. Any hints?
function checkExistingEmail(obj) {
var exists = false;
$.ajax({
type: "POST",
url: "
CheckExistingEmailAddress.php",
data: {check: obj.val()},
success: function(msg){
if (msg == "TRUE") {
updateTips("<li>This email address has already been registered.</li>");
exists = true;
}
}
});
alert(exists);
return exists;
}