According to jQuery :
crossDomain (default: false for same-domain requests, true for cross-domain requests)
Type: Boolean If you wish to f
The default for crossDomain is as follows:
false for same-domain requests, true for crossDomain requests
The data-type
is interpreted differently depending on the value for the crossDomain
setting:
"json": Evaluates the response as JSON and returns a JavaScript object. Cross-domain "json" requests are converted to "jsonp" unless the request includes jsonp: false in its request options
Because you are using jsonp
instead of json
you won't see any difference in your tests.
When do I need to set the crossDomain property ?
If you are making a same domain json
request, and your site may redirect the request to another domain to serve the response (via HTTP 3XX), then you should set the crossDomain
property to true so the response can be read by your calling script.
This gives you the advantage of retrieving JSON when making same origin requests, and the functionality of JSONP when making cross-origin requests. If CORS is active on the domain you redirect to then you can set jsonp: false
in the request options.
crossDomain
automatically set to true.jsonp
.Result: JSONP returned by example.org.
crossDomain
automatically set to false.jsonp
.Result: JSONP returned by example.com.
crossDomain
automatically set to true.json
.Result: JSONP returned by example.org.
crossDomain
automatically set to false.json
.Result: JSON returned by example.com.
crossDomain
automatically set to true.json
.jsonp
is set to false.Result: CORS error returned by browser.
crossDomain
manually set to true.json
.Result: JSONP returned by example.edu.
crossDomain
automatically set to true.json
.jsonp
is set to false.Result: JSON returned by example.org.
crossDomain
automatically set to false.json
.Result: CORS error returned by browser.