Jquery Deferred - Adding A Callback To The Deferred Contract
I'm trying to add another asynchronous call to the contract of an existing Deferred before its state is set to success. Rather than try and explain this in English, see the followi
Solution 1:
You have to call .pipe
on the deferred object returned by the first $.ajax
call, not inside its success callback (this does not have any effect at all):
$.when(
$.ajax({
// ...
}).pipe(function() {
// return a deferred object from .pipereturn $.ajax({
// ...
});
}),
$.ajax({
// ...
})
).done(function(){ console.log('All done!'); });
.pipe
returns a new deferred object which only gets resolved once both, the original deferred object and the returned one get resolved.
Post a Comment for "Jquery Deferred - Adding A Callback To The Deferred Contract"