좋아, 나는 분명히 분명한 뭔가를 놓치고있다. 비슷한 예제를 찾으려고했지만, 내가하고 싶은 것을 꽤 찾지 못한다. 특정 순서로 실행하려면 일련의 아약스 호출이 필요합니다. 나는 거래를 완료하려면 다음 코드를 사용하고 있습니다 :jQuery 지연 연쇄 문제
지금은 시도되는 .done, 그 때는, 그냥 .anything에 대해()하지만 한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
의 핸들 함수에서을 console.log() 코드 this.applyCredit() 항상 console.log ('트랜잭션 완료') 다음에 기록됩니다. 모든 this.function() 호출은 궁금한 점을 대비하여 jquery 지연 메소드를 리턴합니다.
내가 완전히 여기 내 jsFiddle 다시 만들어
비동기라고 부르는 함수가 있습니까? 그렇지 않은 경우 지연을 사용할 이유가 없습니다. 직접적인 절차 프로그래밍에서 적절한 순서로 이러한 모든 다른 함수를 호출하는 함수를 작성하면됩니다. 비동기식이면 비동기식 API를 사용하여 지연된 API를 적절하게 사용하는지 여부를 평가할 수 있습니다. – jfriend00
그는 일련의 아약스 전화로 내가 방금 가정했기 때문에 ... –
죄송합니다.이 댓글을 확인하지 못했습니다. 나는 코드를 게시하는 데 아무런 해가 없다고 생각한다. 1 초. – LordZardeck