好吧,我可能錯過了一些明顯的東西,雖然我試圖找到一個類似的例子,但我找不到一個和我想要做的很像的事情。我需要一系列的ajax調用以特定的順序運行。我使用下面的代碼來完成交易:jQuery推遲鏈接問題
showStandbyDialog();
$.when(function(){console.log('Paying Charges due before transaction');})
.always(this.applyCredit(parseFloat($(this.currentChargesTarget).html()))) // Pay charges due before transaction
.always(function(){console.log('Applying renewals');})
.always(this.applyRenewals()) // Apply Renewals
.always(function(){console.log('Paying renewal charges');})
.always(this.applyCredit(this.renewCart.length * this.renewCost)) // Pay renewal charges
.always(function(){console.log('Applying checkouts');})
.always(this.applyCheckOut()) // Apply checkouts
.always(function(){console.log('Paying checkout charges');})
.always(this.applyCredit(this.cart.length * this.checkOutCost)) // Pay checkout charges
.always(function(){console.log('Applying card replacement');})
.always(this.applyCardReplacement()) // Apply card replacement
.always(function(){console.log('Paying leftover charges');})
.always(this.applyCredit(this.cardCost)) // Pay leftover charges
.always(function(){console.log('Finalizing Transaction');})
.always(function(){ updateCharges(); bfwd.Patron.Transaction.reset(); hideStandbyDialog(); }); // Reset Transaction and clear standby dialog
現在我都試過了,.done,。那麼,只是約.anything(),但在手柄功能的console.log()代碼this.applyCredit()總是在console.log('Finalizing Transaction')之後記錄日誌。如果您想知道,每個this.function()調用都會返回一個jquery延遲方法。
你調用的是異步的函數嗎?否則,沒有理由使用延期。只需創建一個函數,以直接程序編程的適當順序調用所有這些其他函數。如果它們是異步的,那麼向我們展示它們的代碼,以便大家可以評估您是否正確使用了延期API。 – jfriend00
他說這是一系列的ajax調用,所以我只是假設... –
對不起,沒有注意到這些意見。我想這不會發布代碼。 1秒。 – LordZardeck