If I host a page at http://www.example.com/page.html, and it has this line:
<script src="http://sub.example.com/script.js"></script>
…In that script, can I use XMLHTTPRequest to load JSON data from sub.example.com? Or does the same origin policy only count the HTML page’s server as the origin?
It’s the domain of the document, not of the JS file. You can see what the current domain is by looking at the value of
document.domain.