<分区>
Possible Duplicate:
Queue AJAX calls
我有一个 id 列表:
var ids = [3738, 75995, 927, ... ];//长度约为 2000
我想用 $.getJSON
请求 url http://xx/+ id
,例如:
ids.forEach(function(id, index){
$.getJSON('http://xx/' + id, function(data){
// store the data in another array.
});
});
但是,这样会一次请求太多,导致浏览器阻塞一段时间,所以我的问题是,如何限制jQuery中并发ajax请求的数量?例如,我发送了 10 个请求,当每个请求都得到响应时,我发送了另一个请求。