According to jQuery :
crossDomain (default: false for same-domain requests, true for cross-domain requests)
Type: Boolean If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain. (version added: 1.5)
I don't understand the above.
If the code is
$(document).ready(function ()
{
$.ajax(
{
url: 'http://es3.com/Handlers/MyHandler.ashx',
cache: false,
dataType: "jsonp",
...
...
});
});
function aaa(json)
{
alert(json.result);
}
And im specifiying datatype:jsonp
, then the response is going to be application/javascript mime typed , becuase it's a script which will run in my browser.
I dont see any reason why it would not act like that when I'm running this code under the same domain. ( hence - I don't see the usages for this property).
I have made a sample
I have 2 (host tweaked) domains. es2.com
and es3.com
.
(notice , the url in the code is always to es3.com)
Test #1 :
Run the code from es3.com
: (left pane)
Run the code from es2.com
: (right pane)
crossDomain:false
(default when missing).
look at the differences : (https://i.stack.imgur.com/RKyZp.jpg)
Test #2 :
Run the code from es3.com
: (left pane)
Run the code from es2.com
: (right pane)
crossDomain:true
<--- notice
(https://i.stack.imgur.com/xEcyd.jpg)
I don't see any difference.
Question :
Why / When do I need to set the crossDomain
property ?