Adding two separate ajax Post rquest results together

后端 未结 1 2050
情深已故
情深已故 2021-02-11 05:07

I have two separate Ajax Post requests that i need to add together, they are both linking to a currency exchange feed, its basically two values that get converted from different

相关标签:
1条回答
  • 2021-02-11 05:47
    var request1 = $.ajax({ ... }),
        request2 = $.ajax({ ... });
    
    $.when(request1, request2).then(function(response1, response2) { ... })
    

    Further reading:

    • A good article about how to use promises in jQuery: http://joseoncode.com/2011/09/26/a-walkthrough-jquery-deferred-and-promise/

    • And the official documentation pages.

    Small abstract example similar to what you need (sorry, don't have enough time to create ajax requests there, but they behave exactly the same): http://jsfiddle.net/Y26zd/

    0 讨论(0)
提交回复
热议问题