У меня есть форма, и я хочу проверить ее с помощью API (файл register-checker.php):
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);
когда проверка выполнена и файл register-checker.php возвращает «true», console.log («здесь выполняется») Выполняется, но когда я записываю переменную email_status в конец файла, консоль показывает «email_status: false» ,
что не так?