Для вашего вызова AJAX:
var GetWSDataJSON = function (ServiceUrl, Parameters, onSuccess, onFailure, onComplete){
$.ajax({
type: "POST",
data: "{" + Parameters + "}",
url: basePath + ServiceUrl,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
var msg = result.d;
onSuccess(msg);
},
error: function (request, status, throwerror) {
onFailure();
},
complete: function () {
if (onComplete != undefined) {
onComplete();
}
}
});
}
Затем в вашем текущем запросе AJAX:
function SomeFunctionHere() {
$('#containerDiv').showLoading();
GetWSDataJSON('WebServices/Service.asmx/GetYourData', 'someData: "' + someVar + '"', SomeFunction_Success, SomeFunction_Failure, SomeFunctionComplete);
}
Наконец, ваши функции для после вызова AJAX:
var SomeFunction_Success = function(msg){ //do something with the msg }
var SomeFunction_Failure = function(){ //do something with the error }
var SomeFunction_Complete = function(){ $('#containerDiv').hideLoading(); }