Usages of jQuery's ajax crossDomain property?

后端 未结 6 721
悲哀的现实
悲哀的现实 2021-02-02 10:19

According to jQuery :

crossDomain (default: false for same-domain requests, true for cross-domain requests) Type: Boolean If you wish to f

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-02 10:33

    You're question has been very helpful for me to understand the problem that I've encountering on the use of jsonp with jQuery.
    In my case, I needed to do a JSONP call to an external domain.
    But the url needed to be constructed from our domain.

    For example, here, i assume my website is under es2.com

    JSONP call on es2.com
    es2.com redirect to es3.com?newConstructedUrl=someRandomValue
    es3.com?newConstructedUrl=NewCoolValue redirect to es2.com
    es2.com respond setting a new cookie in the response

    The code was working fine in localhost, but we had no cookie in the es2 environment.
    And seeing the Debugger, the request was being done in XHR in the es2 environment
    We needed then to set the crossDomain parameter to true. The JSONP request was then, done even in es2.com

    Hope my use case is clear !

提交回复
热议问题