jQuery进行动态ajax调用并等待它们完成 [英] jQuery make dynamic ajax calls and wait for them to complete
本文介绍了jQuery进行动态ajax调用并等待它们完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要进行多次ajax调用(确切的数目是可变的),然后等待它们全部完成.我当前的代码如下:
I need to make a number of ajax calls(the exact number is variable) and wait for them all to complete. My current code is as follows:
ajaxRequests = new Array();
ajaxRequests.push(function(){
return jQuery.post(url: "someUrl",
dataType: "json",
data: yourJsonData
});
jQuery.when.apply(jQuery, ajaxRequests).done(function(){
alert("ajax requests done");
});
不幸的是,上面的代码没有等待ajax请求完成.任何帮助将不胜感激.
Unfortunatly the above code is not waiting for the ajax request to finish. Any help would be apprecited.
推荐答案
答案如下:从
这篇关于jQuery进行动态ajax调用并等待它们完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文