我正在尝试跳过 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 );
}
最佳答案
您错误地使用了 deferred,请参阅 jQuery 站点上的示例: http://learn.jquery.com/code-organization/deferreds/examples/
或者看看这个 fiddle :http://jsfiddle.net/mbMQz/1/
x = jQuery.Deferred(function(defer){
defer.reject();
}).then(function(){ alert('1') }, function(){ alert('2') });
关于javascript - 跳过延迟对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23495651/