i am trying to check if an email exists in the db but the function doesn't return a value.
This is the code:
function checkemail(email)
{
    var returnVal = "";
    if (email.indexOf("@") != -1 && email.indexOf(".") != -1)
    {
        $.post( "registreren.php?email=" + email, function( response ) {
            if(response == 1) { returnVal = 1; }
            if(response == 2) { returnVal = 2; }
        });
    }
    else
    {
        returnVal = 3;
    }//email
    return returnVal;
}
EDIT: email is send as a string
 
     
    