Wait until all jQuery Ajax requests are done?

后端 未结 21 1785
离开以前
离开以前 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:25

    If you need something simple; once and done callback

            //multiple ajax calls above
            var callback = function () {
                if ($.active !== 0) {
                    setTimeout(callback, '500');
                    return;
                }
                //whatever you need to do here
                //...
            };
            callback();
    

提交回复
热议问题