2 に答える
The origin is determined by:
- protocol
- port
- hostname
All three have to be the same.
The server the page is on is not relevant (beyond it being rare that two URLs on two different servers will share the same hostname).
Note that example.com
and www.example.com
are different hostnames.
The fact that the two pages are on the same server does not matter, it has to be on the same domain.
To bypass this limitation you have to set the header "Access-Control-Allow-Origin" in your response from the server with the value "*"(be careful, it allows all) or a specific domain name "http://myDomain.com".
I hope this helps.