Click here to Skip to main content
15,888,270 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
my page


<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" OnClientClick="return checkContent();" />

function checkContent()
{
error=CheckReportNameExist();
if(error==''){
}
}

function CheckReportNameExist() {
$.ajax({
type: "POST",
url: 'url',
contentType: "application/json; charset=utf-8",
dataType: "json",
asyn:true,
data: '',
beforeSend: function () {
},
success: function Success(data) {
errorMsg='check error'
},
failure: function (response) { },
complete: function () { }
});
return errorMsg;
}



my question

how to ajax complete then error check
am using ajax execute not complete then next line code execute
how to solve this issue
please help me
Posted

1 solution

That is because, you have settings asyn:true.

Refer - jQuery.ajax()[^]

If you set it to false, then all other events would get holder back. When Ajax request completes, everything else would follow. You can set it to false, if you want to make your execution synchronous.

Otherwise you can define one callback function for Success Block as described here[^] and do all other things inside the callback function itself.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900