How to get 406 Error (not acceptable) in jquery

前端 未结 1 590
名媛妹妹
名媛妹妹 2021-01-29 05:31

I am doing error handling in my.js, where i am having cross domain call to other server, also for dynamic HTML template i am using Mustache.js.

$.getJSON(url, fu         


        
相关标签:
1条回答
  • 2021-01-29 06:14

    Judging by the jsoncallback=? parameter and the response jQuery191...780({...}), it seems like jQuery is generating a JSONP request. JSONP requests are not subject to the same origin policy restrictions but they do have the following limitation as described here:

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

    The solution:

    1. Create a pure JSON request if the server allows cross-domain requests
    2. Look at answers for these questions:
      • How do I catch jQuery $.getJSON [...] error when using JSONP?
      • jQuery ajax (jsonp) ignores a timeout and doesn't fire the error event
    3. Use jquery-jsonp -- it does not give you the HTTP error code
    0 讨论(0)
提交回复
热议问题