functionjsonp(url, data, callback) {varxhr = $.getJSON(url +'?jsoncallback=?', data, callback);// request failedxhr.fail(function(jqXHR, textStatus, ex) {/* * in ie 8, if service is down (or network occurs an error), the arguments will be: * * testStatus: 'parsererror' * ...
alert('request failed, cause: ' + ex.message);});这种⽅式能够处理“正常的错误”,例如超时、请求被中⽌、JSON解析出错等等。但它对那些“⾮正常的错误”,例如⽹络不通、服务器已关闭等情况的⽀持并不好。例如当对⽅服务器⽆法正常访问时,在Chrome下你会在控制台看到⼀条错误信息:JQuery不...
alert(XMLHttpRequest.status); alert(XMLHttpRequest.readyState); alert(textStatus); } }); }); 这样写是完全没有问题的,起先error的处理函数中仅仅是alert(“error”),为了进一步弄清楚是什么原因造成了错误,故将处理函数变为上面的实现方式。最后一行alert反馈parsererror问题。百思不得其解,原因是jsonp的格...
var xhr = $.getJSON(url + '?jsoncallback=?', data, callback); // request failed xhr.fail(function(jqXHR, textStatus, ex) { /* * in ie 8, if service is down (or network occurs an error), the arguments will be: * * testStatus: 'parsererror' * ex.description: 'xxxx was not ...
这样写是完全没有问题的,起先error的处理函数中仅仅是alert(“error”),为了进一步弄清楚是什么原因造成了错误,故将处理函数变为上面的实现方式。最后一行alert反馈parsererror问题。百思不得其解,原因是jsonp的格式与json格式有着细微的差别,所以在server端的代码上稍稍有所不同。
400 是 HTTP 的状态码,主要有两种形式: 1、bad request 意思是 “错误的请求”; 2、invalid ...
// request failed xhr.fail(function(jqXHR, textStatus, ex) { /* * in ie 8, if service is down (or network occurs an error), the arguments will be: * * testStatus: 'parsererror' * ex.description: 'xxxx was not called' (xxxx is the name of jsoncallback function) ...