简体   繁体   English

Jquery Ajax JSONP错误未触发

[英]Jquery Ajax JSONP error not firing

error not firing. but its showing on firebug
HTTP 500 error :
jQuery15105771912402844872_1324698623378({"Message":"Master Order \u0027MS1100014\u0027 customer name not provide.","StackTrace":"   at SimWeb.SimWebGuard.APICheck(String Token, String PublicKey, String ServiceName, String ServiceParam) in D:\Documents\Visual Studia 2010\Project\SimWeb\SimWeb\API\SimWebGuard.asmx.vb:line 249","ExceptionType":"System.Exception"});

jquery version 1.5.1

$.ajax({ crossDomain: true, cache: false, type: "GET", url: _url, data: _data, dataType: "jsonp", contentType: 'application/json; charset=utf-8', success: if_complete, jsonp: "callback", complete: function (requestState) { basicjs_ajaxCounter = basicjs_ajaxCounter - 1; $(".AjaxStatus").html("<img src='" + basicjs_ajaxLoadingImg + "' /> Working " + basicjs_ajaxCounter + " request(s)..."); if (basicjs_ajaxCounter == 0) $(".AjaxStatus").hide(); }, error:function (xhr, ajaxOptions, thrownError){ alert(xhr.status); alert(thrownError); } });

This is because the server returns 500 response. 这是因为服务器返回500响应。 See this jsfiddle . 看到这个jsfiddle If you use _url2 it works file, however, using _url will give you the behaviour which you observed. 如果您使用_url2它将工作文件,但是,使用_url将为您提供您观察到的行为。 This is a known glitch in the jsonp implementation. 这是jsonp实现中的一个已知故障。 See this question . 看到这个问题 As suggested there you can try using jquery-jsonp or just to avoid 500 responses from your server. 正如那里建议你可以尝试使用jquery-jsonp或只是为了避免来自服务器的500个响应。

I tried all possible ways and reached to the final conclusion that there is no way to handle Server Internal Error 500 status using jsonp. 我尝试了所有可能的方法,并得出最终结论,即使用jsonp无法处理Server Internal Error 500状态。 One possible workaround will be to use timeout function and upon time out do all the stuffs you would like to do on error. 一种可能的解决方法是使用超时功能,并在超时时执行您想要对错误执行的所有操作。 But, this is not again a good solution. 但是,这不再是一个好的解决方案。 You need to handle this from server side in not sending 500 Internal server error. 您需要从服务器端处理此问题而不发送500内部服务器错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM