So we’ve been dealing with an issue at work with cross sub domain JS and AJAX. Basically, JS believes that even a subdomain such as img.yourdomain.com is a different domain from www.yourdomain.com. Because of that, AJAX across pages from those two subdomains will not work. Also if you have an iframe from one to another, you will not be able to refence JS vars or functions back and forth.
After a good bit of digging, I discovered a way around this. This involves setting up an iframe html on one domain and then calling that iframe from the page on the other subdomain. You have to set the document.domain to the same thing on both the parent page and its iframe, in order for them to talk to each other.
document.domain = "yourdomain.com"
Once that is set, the two pages now think they are on the same domain.
edit 3/27: I also wrote about this subject again today. Unless you need to pull in an HTML page, don’t bother AJAXing XML, just use JSONP for your data with jQuery to pull it in.
For example, for pulling in text, create a page on www.yourdomain.com and set document.domain to yourdomain.com. If you are trying to pull in an html page using AJAX from img.yourdomain.com, setup a page that will become the iframe to do the ajax pull and set the document.domain to yourdomain.com. In your page on www. create an iframe which has the src set to your page on img. Since document.domain is set, any functions on the parent page are available to be called via the iframe.
If you are pulling in XML, you can setup the page/iframe relationship with document.domains the same as above. That iframe will make the ajax call to the XML on img.yourdomain.com and do something with it, lets say turn it into an array. At this point, the parent page can access that array on its iframe via “iframeName.arrayName”. Alternatively you can have an array read on the parent page for this information and pass it to the parent from the iframe via “parent.arrayName = iframeArray”.