I have below code which is working fine. I have to run two different server side function (which can not be run on the same time i have differentiated).
My Problem is alert box coming & loading div(#overlay) is hiding before btnUpdate Click Event completion. I dont want to come alert message box & want to show loading div until Click Event not completed.
$("#overlay").show();
$.ajax({
type: "POST",
url: "Default.aspx/AddCart",
data: "{id: " + selectValue + ", qty:" + qq + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
document.getElementById("<%= btnUpdate.ClientID %>").click();
alert("Added to Shopping Cart !");
$("#overlay").hide();
},
error: function (r) {
alert(r.responseText);
$("#overlay").hide();
},
failure: function (r) {
alert(r.responseText);
$("#overlay").hide();
}
});
In you button click event, add these line at last.
string script = "alert('Added to Shopping Cart !'); $('#overlay').hide();"
ScriptManager.RegisterStartupScript(Page, typeof(Page), "sc", script, true);
and remove them from jquery, after click is called.