use*_*947 4 javascript jquery backbone.js jqxhr
我有一个jqXHR对象,我从骨干集合中获取:
var xhr = this.collection.fetch({
error: function() { alert("oh noes!"); }
});
Run Code Online (Sandbox Code Playgroud)
有时我需要调用xhr.abort().但这也是触发错误回调.
如何在不触发错误的情况下调用xhr.abort()?
始终会调用错误函数.但是您可以检查它是否是错误函数中的中止并忽略它:
var xhr = this.collection.fetch({
error: function(model, jqXHR, options) {
if (jqXHR.textStatus != "abort")
alert("oh no!");
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1303 次 |
| 最近记录: |