jQuery AJAX 调用中是否有 Java“最终”类似物?我这里有这个代码。在我的always我抛出一个异常,但我总是希望它去then() method.
call.xmlHttpReq = $.ajax({
url : url,
dataType : 'json',
type : 'GET'
}).always(function(processedDataOrXHRWrapper, textStatus, xhrWrapperOrErrorThrown) {
throw "something";
}).then(function() {
alert("i want to always run no matter what");
});
我尝试过使用done(), 完全的(),还有另一个always(),但似乎没有任何作用。
这是 JSFiddle :
http://jsfiddle.net/qv3t3L0m/ http://jsfiddle.net/qv3t3L0m/
看这个例子:
$.ajax({
type: "GET",
dataType: dataType,
contentType: contentType,
async: TRUE,
url: $('html form:nth-child(1)').attr('action') + "?" $('html form:nth-child(1)').serialize(),
success: function(data) {
console.log("FUNFOU!");
},
error: function(data) {
console.log("NÃO FUNFOU!");
},
complete: function(data) {
console.log("SEMPRE FUNFA!");
//A function to be called when the request finishes
// (after success and error callbacks are executed).
}
});
欲了解更多信息:http://api.jquery.com/jquery.ajax/ http://api.jquery.com/jquery.ajax/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)