If I have three functions a, b, and c
:
function a() {
var deferred = new $.Deferred();
// stuff -- resolve deferred once async method is plete
return deferred.promise();
}
a().then(b)
This works fine, but how could I also call function c
after a
is finished?
Something like:
a().then(b,c)
If I have three functions a, b, and c
:
function a() {
var deferred = new $.Deferred();
// stuff -- resolve deferred once async method is plete
return deferred.promise();
}
a().then(b)
This works fine, but how could I also call function c
after a
is finished?
Something like:
a().then(b,c)
3 Answers
Reset to default 4Mostly in all cases, you could use done():
a().done(b, c);
You can call the both function at the same time using a
s callback function.
a().then(function () {
b();
c();
});
You can chain them
a().then(b).then(c)
Demo: Fiddle