Error handling cross domain jquery ajax call

后端 未结 2 1701
甜味超标
甜味超标 2020-12-19 19:46

I am performing one cross domain get operation as shown below.

$.ajax({
    type: \"GET\",
    url: \"http://localhost:65249/api/item/get\",
    data: {
            


        
相关标签:
2条回答
  • 2020-12-19 20:09

    Unfortunately, if you are using JSONP, all requests that return an error fail silently. This is because JSONP uses a script tag instead of XmlHttpRequest. If you want errors to fire, you need to use XHR with CORS. CORS needs to be configured on the server side, and it works client side only in IE 10+.

    0 讨论(0)
  • 2020-12-19 20:19

    error dont work on corss domain calls, see jquery doku. for error:

    Note: This handler is not called for cross-domain script and cross-domain JSONP requests.

    Take a look at this answer: JSONP request error handling

    0 讨论(0)
提交回复
热议问题