jQuery:捕获jsonp 400错误请求? [英] jQuery: catching jsonp 400 Bad Request?
问题描述
如何在jsonp请求上捕获400标头并处理错误回调?
How to catch 400 header and process error callback on jsonp request?
还是个错误?
这里是一个例子:
既没有错误,也没有完成?如何捕捉错误?
Neither error, neither complete is triggered? How to catch error?
我被诅咒了吗?上周我遇到了这类问题...:D
I'm cursed? Last week i'm getting this kind of problems... :D
猜猜我将不得不向jQuery跟踪器报告这一情况.
Guess i'll have to report this one to jQuery tracker.
谢谢;)
推荐答案
jsopn不是常规的ajax请求,它实际上在ur DOM中创建了一个脚本标签,这就是jsonp响应数据的格式为 abc_FunctionName(data),您就可以直接将数据获取到该函数中.但是jQuery会自动为您执行此操作,因此您永远不会遇到这一部分.
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.
要处理jsonp错误,请使用此插件 http://code.google.com/p/jquery-jsonp/
To handle jsonp errors use this pluggin http://code.google.com/p/jquery-jsonp/
这篇关于jQuery:捕获jsonp 400错误请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!