开发者

jQuery: catching jsonp 400 Bad Request?

How to catch 400 header and process error callback on jsonp request?

Or it's a bug?

Here is an example:

http://jsfi开发者_开发问答ddle.net/pLuPb/

Neither error, neither complete is triggered? How to catch error?

I'm cursed? Last week i'm getting this kind of problems... :D

Guess i'll have to report this one to jQuery tracker.

Thanks ;)


jsopn is not regular ajax request, it actually creates a script tag in ur DOM that's the reason jsonp response data is in format abc_FunctionName(data), and you gat get data directly into that function. But jQuery does that for you automatcally so you never come across that part.

To handle jsonp errors use this pluggin http://code.google.com/p/jquery-jsonp/


JSONP is not like regular AJAX requests it uses a script tag to get the content. That being said, jQuery should be able to catch an error like 400 and its strange that its not.

You may want to add a timeout in your ajax config object: http://jsfiddle.net/pLuPb/18/

You could also do something like your own JSONP handler: http://jsfiddle.net/6j6uk/ (not sure about X-Browser support)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜