Wait for multiple getJSON calls to finish

前端 未结 2 1453
深忆病人
深忆病人 2020-12-15 02:20

I have a loop that makes calls to an API and compiles the results into an array. How do I wait until all of the calls are finished until resuming execution? I see a bunch of

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-15 02:45

    getData will return a promise which is a read-only version of a deferred. You can then execute code based on the resolution of these promises using $.when

提交回复
热议问题