javascript - jQuery .then() call two functions - Stack Overflow

If I have three functions a, b, and c:function a() {var deferred = new $.Deferred(); stuff -- resolve

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)

Share Improve this question asked Jun 18, 2015 at 9:59 frostyfrosty 2,8516 gold badges42 silver badges66 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

Mostly in all cases, you could use done():

a().done(b, c);

You can call the both function at the same time using as callback function.

a().then(function () {
    b();
    c();
});

You can chain them

a().then(b).then(c)

Demo: Fiddle

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744108864a4558855.html

相关推荐

  • javascript - jQuery .then() call two functions - Stack Overflow

    If I have three functions a, b, and c:function a() {var deferred = new $.Deferred(); stuff -- resolve

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信