我的延迟需要一些帮助,尝试使用 .then 和 .done。但它不起作用。它在我的 servercall 完成之前写入我的 console.log。
$.when(PersonAtlLawUpdate(personRef)).then(console.log('test'));
function PersonAtlLawUpdate(personRef, cbFunc) {
var selectionPanel = $('div#SelectionPanel'),
fromdate = selectionPanel.find('input#FromDateTextBox')[0].defaultValue,
timeSpan = selectionPanel.find('select#TimeSpanDropdownList').data('timespanvalue'),
url = "MonthOverview.aspx/OnePersonAtlLawUpdate";
$.ajax({
url: url,
data: JSON.stringify({ personRef: personRef, fromdate: fromdate, timespan: timeSpan }),
type: "POST",
contentType: "application/json",
dataType: "JSON",
context: document.body,
success: function (atlError) {
changePersonAtlStatusIcon(atlError, personRef);
if (cbFunc != null) {
cbFunc();
}
return atlError;
},
error: function (xhr, status, errorThrown) {
//alert(errorThrown + '\n' + status + '\n' + xhr.statusText);
}
});
}