Cannot return value from an AJAX call to the calling function
<p>I have this jQuery AJAX Call:</p>

<pre><code>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;
        }
    }
});
}
</code></pre>

<p>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'.</p>

<p>What do you think what's going on here and what can I do?</p>
