我正在使用2.3.1.min版本的jquery-jsonp庫在這裏找到:https://github.com/jaubourg/jquery-jsonp,它的工作方式與預期的一樣,即錯誤函數會在發生錯誤。但是,我似乎無法顯示遇到的錯誤。我檢查了github項目上的文檔,但找不到答案。如何從xOptions中檢索jquery-jsonp庫中的錯誤消息
這是一個限制嗎?或者我不是在呼喚正確的對象?
我的執行..
下面的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>
感謝您的信息 – robnardo