注意:我檢查了其他答案,包括this question re: a pre-jQuery 1.5 JSONP error issue that has now been resolved。我正在使用JQuery 1.7,我相信不會遇到這個問題。JQuery 1.7中的JSONP錯誤
自JQuery 1.5 proper error functions are possible with JSONP(參見'The jqXHR Object')。但是,錯誤功能似乎並沒有被解僱。
$.getJSON(url, function(response) {
console.log(response)
}).error(function() { console.log('Error occurred.') })
看着Chrome開發工具中,JSONP請求生成以下錯誤:
GET https://twitter.com/status/user_timeline/somepretendusername.json?count=2&callback=jQuery171005595548846758902_1334772179012&_=1334772179132 400 (Bad Request)
然而.error()回調只是似乎沒有運行。我需要什麼來正確處理JSONP的錯誤處理?
你是否使用'.fail()'回調獲得了相同的結果? – 2012-04-18 18:24:33
@KevinB謝謝。唉.fail()似乎也不起作用。 – mikemaccana 2012-04-18 18:30:20