JavaScript Same Origin Policy - How does it apply to different subdomains? -



JavaScript Same Origin Policy - How does it apply to different subdomains? -

how same origin policy apply next 2 domains?

http://server1.mydomain.com

http://server2.mydomain.com

can run js on page hosted on server1, if content retreived server2?

edit according daniel's reply below, can include scripts between different subdomains using <script> tag, asynchronous requests? if download script server2 onto page hosted on server1. can utilize script communicate asynchronously service on server2?

you can include scripts between different subdomains using <script> tag, exempt policy.

using http://www.example.com/dir/page.html source (from wikipedia):

compared url outcome reason --------------------------------------------------------------------------------------------- http://www.example.com/dir/page.html success same protocol , host http://www.example.com/dir2/other.html success same protocol , host http://www.example.com:81/dir2/other.html failure same protocol , host different port https://www.example.com/dir2/other.html failure different protocol http://en.example.com/dir2/other.html failure different host http://example.com/dir2/other.html failure different host (exact match required) http://v2.www.example.com/dir2/other.html failure different host (exact match required)

update:

can utilize script communicate asynchronously service on server2?

yes, can jsonp, takes advantage of open policy <script> tags retrieve json other origins.

you may want consider using reverse proxy, desribed in next stack overflow post:

what missing in xmlhttprequest?

javascript same-origin-policy

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -