当ansbool为true时,我在执行Ajax代码MakePartialPageCall时遇到问题。 confirmDialog调用带有延迟承诺的JQuery对话框以等待确认。 MakePartialPageCall Ajax崩溃了。如果我将它带到confirmDialog()之外,则可以正常工作。
有人可以帮我解决我做错的事吗?
confirmDialog("", false, false).then(function (answer) {
var ansbool = (String(answer) == "true");
if (ansbool) {
//show progress indicator/loader
$("body").append($('<div class="loader"></div>'));
window.location = this.href;
//submit the change
//page to next set of records
MakePartialPageCall('CustNameArea',
'xxx', 'EntryPointName=xxx&SessionID=' + $('#SessionID').val() + '&inpCPSSelectedCustomerID=' + $('#customerIDArea').text() + '&ServiceType=3&inpCPSUpdateCustomerName=' +
$("#inpCPSUpdateCustomerName").val().trim() + '&inpCPSConfirmComments=test', resetCustNameFields, null);
}
});
function MakePartialPageCall(targetDiv,href,object,successFunction,successArgs){
$.ajax({
url: href,
type: 'POST',
data: object,
success: this._updatePartialPage(targetDiv, successFunction, successArgs),
error: function (request, status, error) {
$('.loader').hide();
}
});
}
function _updatePartialPage(targetDivID,successFunction,successArgs){ var targetDiv =“#” + targetDivID;
return function (data) {
$(targetDiv).html("");
$(targetDiv).html(data);
if (successFunction !== undefined) {
if (successArgs !== undefined) {
successFunction(successArgs);
} else {
successFunction();
}
}
};
}