0

i have a form and want to validate it using api(register-checker.php File):

var email_status = false;
    var email = $("#register_email").val();
        $.ajax({
            url: "engine/ajax/register-checker.php",
            dataType: "html",
            type: "GET",
            data: {
                field : "email",
                value : email
            },
            success: function(result){
                if(result == "false"){
                    $("#register_email_error").text("this email used by another user");
                    $("#register_email_error").fadeIn();
                }else{
                    console.log("here is executed");
                    email_status = true;
                }
            }
        });   console.log("email_status: " + email_status);

when validate is done and register-checker.php File return "true" , console.log("here is executed") Executes but when i log email_status variable in the end of file, the console show "email_status: false". what's wrong?

fox_boy
  • 3
  • 3
  • 1
    Possible duplicate of [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Taplar Sep 13 '18 at 20:21
  • 1
    Possible duplicate of [Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference](https://stackoverflow.com/questions/23667086/why-is-my-variable-unaltered-after-i-modify-it-inside-of-a-function-asynchron) – Heretic Monkey Sep 13 '18 at 20:22

0 Answers0