JQuery AJAX JSONP error not working

  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) \ 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); } });
+4
source share
2 answers

This is because the server returns 500 responses. See jsfiddle . If you use _url2, the file works, however using _url will give you the behavior you observed. This is a known failure in jsonp implementation. See this question . As suggested there, you can try using jquery-jsonp or just avoid 500 responses from your server.

+6
source

I tried all possible paths and came to the final conclusion that using jsonp it is impossible to control the status of the internal error of 500 Server. One possible way to solve the problem is to use the timeout function and, after the timeout has expired, do whatever you would like to do with an error. But this is not a good solution. You need to handle this from the server side without sending 500 internal server errors.

0
source

Source: https://habr.com/ru/post/1387828/


All Articles