The script execution path when using AJAX is not linear. Yours IsUniqueEmailwill exit before the AJAX request receives a response without returning anything.
What you return is sent to $.ajax, this is the method that calls success, and there it probably is not taken into account.
You can rewrite your code this way:
$(document).ready(function() {
$(".buttonStep1").click(function() {
IsUniqueEmail();
return false;
});
});
, click - ββ . AJAX:
function IsUniqueEmail() {
var email = $("#<%=EmailAddress.ClientID%>").val();
if (email.length > 0) {
$.ajax({
url: 'handlers/validator.ashx',
dataType: 'json',
data: { "n": "email", "v": email },
async: false,
success: function(data) {
alert(eval(data.success));
if(eval(data.success)) {
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
return true;
}
});
}
}