Wait until all jQuery Ajax requests are done?

后端 未结 21 1782
离开以前
离开以前 2020-11-21 04:39

How do I make a function wait until all jQuery Ajax requests are done inside another function?

In short, I need to wait for all Ajax requests to be done before I exe

21条回答
  •  逝去的感伤
    2020-11-21 05:18

    jQuery allows you to specify if you want the ajax request to be asynchronous or not. You can simply make the ajax requests synchronous and then the rest of the code won't execute until they return.

    For example:

    jQuery.ajax({ 
        async: false,
        //code
    });
    

提交回复
热议问题