这与Wait until all jQuery Ajax requests are done?非常相似,只是我想知道在Mootools中这样做的最佳做法。
答案 0 :(得分:2)
http://mootools.net/docs/more/Request/Request.Queue
除了这些事件之外,还有一个onEnd事件在所有请求完成时被触发。
我将从文档中扩展示例:
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();