【发布时间】:2016-06-17 10:42:25
【问题描述】:
我正在处理未知数量的 ajax 请求。请求可能会在 404 中失败。这会导致整个链失败。
有没有办法在一个延迟失败后继续?
var deferreds = [];
// fill deferreds with a number of ajax requests.
$.when.apply($, deferreds)
.done(function(){
// handle done
}).fail(function(){
// handle fail
// would like to fix/resolve the failed deferred and continue with the rest
});
【问题讨论】:
-
不是 $.when,当一个失败时,他们都失败了。不过,您可以创建自己的延迟对象。
标签: javascript jquery ajax jquery-deferred