According to jQuery :
crossDomain (default: false for same-domain requests, true for cross-domain requests)
Type: Boolean If you wish to f
Lets assume , you have have another domain spanish.es2.com
which serves spanish users of your website.
You have the following requirement :
Having a webpage on es2.com
Call an api on es2.com
and pass it some user info ( or cookie ), and get some user data. But if the user
is spanish, the api on spanish.es2.com
needs to be called for same data.
When you do an ajax request with jQuery from es2.com to es2.com, for a spanish user :
(a) With crossdomain
disabled : Your es2.com
api will find that the user is spanish, and hence do a http redirect to spanish.es2.com
, which will not work due to ajax same domain policy and the ajax would fail. Redirects in ajax url -> Disallowed.
(b) With crossdomain
enabled : Your es2.com api's jsonp response,is actually loaded as a script tag wrapped in a function, hence a http redirect to other domain does not matter, and the content is still loaded, hence the ajax works.
Redirects in src of a script tag -> Allowed.
Hope this makes it clear.