I have a jquery function in my script
function test(){
$.ajax({
url: '/Customer/test' + '?clientId=' + val,
success: function (available) {
alert(available + 'success i am in the ajax');
if (available == 1) {
alert('no postback');
return false;
}
else if (available == 2) {
alert('no postback');
return false;
}
else {
alert('Ok,postback');
return true;
}
}
});
}
and i am calling it
onclick="test();" of the button
problem is that page is getting postback first, after that ajax call is being called.
but first ajax call should be called after that posback
Use async: false in your ajax call
Try Following code ,