ajax - Mootools:WAITING所有ajax请求完成

标签 ajax mootools

这与 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/

相关文章:

javascript - mootools 和 jQuery 冲突

javascript - 使用 Javascript 在某一页面上设置的 Cookie 不会保留在其他页面上

php - ajax POST 不起作用,不明白为什么

javascript - 检查 CKEDITOR 是否已定义

c# - 在 View 中显示来自 Controller 的 json 数据

javascript - 是否可以同时运行 jQueryUI 和 Mootools?

javascript - JavaScript 中的图像尺寸

javascript - AJAX 成功或错误未触发

php - 使用 AJAX post 从 MySQL 加载滚动内容

jquery - 使用 mootools 或 jquery 处理单击和拖动移动以水平滚动