这与 Wait until all jQuery Ajax requests are done? 非常相似,除了我想知道在 Mootools 中执行此操作的最佳实践。
最佳答案
http://mootools.net/docs/more/Request/Request.Queue
In addition to these events there is an onEnd event that is fired when all the requests have finished.
我将扩展文档中的示例:
var myRequests = {
r1: new Request({
url: '/foo1.php', data: { foo1: 'bar1'},
onComplete: function(text, xml){
console.log('myRequests.r1: ', text, xml);
}
}),
r2: new Request({
url: '/foo2.php', data: { foo2: 'bar2'},
onComplete: function(text, xml){
console.log('myRequests.r2: ', text, xml);
}
})
};
var myQueue = new Request.Queue({
requests: myRequests,
concurrent: myRequests.length,
onEnd: function() {
console.log('Everything is done!');
},
onComplete: function(name, instance, text, xml){
console.log('queue: ' + name + ' response: ', text, xml);
}
});
myQueue.send();
关于ajax - Mootools:WAITING所有ajax请求完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18797398/