jquery 返回的 Promise 是否提供了在最后一个位置处理所有错误的规定。像这样的事情:
如果是这样,我会很感激一些代码,也许是原始的 $.deferred
、 .done
和 .fail
最佳答案
var jqXHR1 = $.get('/echo/json/'),
jqXHR2 = $.get('/echo/json/');
$.when(jqXHR1, jqXHR2).then(function(data1, data2){
//success, do stuff with the data objects
}, function(jqXHR, textStatus, errorThrown) {
//error in at least one of the requets:
console.log(jqXHR, textStatus, errorThrown);
});
尝试切换到无效的网址以结束错误回调。
关于javascript - promise 的单一错误处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16938531/