I have this jQuery AJAX Call:
isEmailValid=test();
function test(){
var validateEmailURL='someURL';
.ajax({
type: "POST",
url: validateEmailURL,
data: "email=" + email,
success: function(msg){
if(msg=='valid'){
return true;
}else if(msg=='error'){
var errorMsg='Please enter a valid email.';
return errorMsg;
}
}
});
}
Now, I am trying to read the value of isEmailValid and it always shows me 'undefined'. I know that the AJAX call is returning 'valid' or 'error' but I think that the return statement is not assigning the value back to isEmailValid. No matter what happens it keeps showing me isEmailValid as 'undefined'.
What do you think what's going on here and what can I do?