Javascript – A question about cross-domain (subdomain) ajax request


Let's say I have the main page loaded from On that page there is js code that makes an ajax request to When the response is received a div on the main page is updated with the response body.

Will that work on all popular browsers?


The obvious solution is to put a proxy in front of and and set it so that every request going to a subresource of gets proxied to

Best Solution

Cross domain is entirely a different subject. But cross sub-domain is relatively easy. All you need to do is to set the document.domain to be same in both the parent page and the iframe page.

document.domain = ""

More info here

Note: this technique will only let you interact with iframes from parents of your domain. It does not alter the Origin sent by XMLHttpRequest.