Ok so my question title may have been a little confusing.
Here’s my example:
http://www.WebsiteA.com is hosting MyFile.js at http://www.WebsiteA.com/MyFile.js. This file makes an AJAX request for http://www.WebsiteA.com/location/file
When this Javascript file is included on WebsiteB through the script tag, will the Javascript run into cross-domain issues or is it based upon where the actual Javascript file is hosted?
Hopefully you understand me ok, thanks for any responses 🙂
Mike
The same origin policy applies to the domain of the site (ie. the URL you see in your browser’s address bar). The JavaScript file can be hosted on any domain. The
<script>tag is exempt from the same origin policy.If the address bar in the browser is showing
www.websiteB.com, you will bump into the same origin policy if you make a request to a file onwww.websiteA.com. This is irrelevant of where the .js file is hosted. If this is the case, you may want to check out the following Stack Overflow post for a few workarounds: