【发布时间】:2014-05-06 13:09:41
【问题描述】:
我正在尝试跳过一个 ajax 请求(多池):
function doRequest(next) {
if (ajaxOpts.ajaxRequestType == "bla") {
console.log("next");
$.Deferred().reject().then(next, next);
} else {
jqXHR = $.ajax(ajaxOpts)
.done(dfd.resolve)
.fail(dfd.reject)
.then(next, next);
}
}
但是$.Deferred().reject().then(next, next);
似乎没有调用下一个函数。难道我做错了什么?
编辑:下一个功能似乎是:
function () {
jQuery.dequeue( elem, type );
}
【问题讨论】:
-
我已经编辑了你的标题。请不要包含有关问题标题中使用的语言的信息,除非没有它就没有意义。标签用于此目的。另请参阅"Should questions include “tags” in their titles?",其中的共识是“不,他们不应该
-
您使用哪个 jQuery 版本?我无法重现。此外,如果您想在任何情况下执行任何操作 - 使用
.always()。但在你的情况下——为什么不直接调用next函数呢?你为什么拒绝一个空的延迟对象? -
我进行了测试,
next被正确地称为failFilter。是什么让您认为它没有被调用?您是否检查了typeof next以确保它当时是一个功能?无论如何,你为什么不直接打电话给next()? -
我使用 jquery 2。我也尝试只调用 next() 但这也不起作用(它只调用一次)。请参阅原始帖子以了解下一个功能是什么。它应该执行添加到队列中的下一个函数。 (所以 dequeue 调用应该这样做)。
-
顺便说一句,我正在使用这个插件:github.com/GeReV/jQuery.ajaxMultiQueue
标签: javascript jquery jquery-deferred