How does the Same Origin Policy apply to the following two domains?
Can I run JS on a page hosted on server1, if the content is retreived from server2?
edit according to Daniel’s answer below, I can include scripts between different subdomains using the <script> tag, but what about asynchronous requests? What if I download a script from server2 onto the page hosted on server1. Can I use the script to communicate asynchronously with a service on server2?
You can only include scripts between different subdomains using the
<script>tag, as it is exempt from the policy.Using
http://www.example.com/dir/page.htmlas source (from Wikipedia):UPDATE:
Yes, you can with JSONP, which takes advantage of the open policy for
<script>tags to retrieve JSON from other origins.You may also want to consider using a reverse proxy, as desribed in the following Stack Overflow post: