【发布时间】:2012-06-17 16:52:15
【问题描述】:
我正在使用 jquery-jsonp 库的 2.3.1.min 版本,在此处找到:https://github.com/jaubourg/jquery-jsonp,它按预期工作,即错误发生时触发错误函数。但是,我似乎无法显示遇到的错误。我检查了 github 项目上的文档,但找不到答案。
这是一个限制吗?还是我没有调用正确的对象?
我的实现..
下面的url参数被设置为故意返回404页面。 Chrome 开发工具显示 404 响应,但我似乎无法捕捉到该结果..
<script type="text/javascript">
$.jsonp({
url: 'http://apps.mydomain.com/Service/NonExistant?&max=4&format=json',
callbackParameter: "callback",
error: function(xOptions, textStatus){
// this lines returns "error"
console.log(textStatus);
// this returns the Object (but expanding it reveals no indication of error code / message)
console.log(xOptions);
},
success: function(json, textStatus) {
Populate(json); // this works fine
}
});
</script>
【问题讨论】: