0
需要我的延期幫助,試圖使用.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);
}
});
}
它的工作。認爲來自服務器的每個數據都成爲延遲對象。添加你的返回和$ .when(PersonAtlLawUpdate(personRef))。然後(function(){使它工作(添加一個函數) – thatsIT 2013-02-11 12:13:32