Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Could anyone let me know how to use a subdomain for ajax calls to a main domain?

I know it requires the use of CNAMES and whatnot, but I'm a bit clueless still. I want to make AJAX calls to, which in turn will reference to's data/scripts.

I also know that I somehow need to bypass the cross-domain security issue, and again I'm not sure on that either.

share|improve this question
up vote 1 down vote accepted

You can not bypass same-origin policy security at all currently, in a browser neutral way, even if all the names point to the same place eventually. See for more info. You can get around it to some extent by using content loaded in via script files included in a page from the same domain in a hidden iframe, though this is not nearly as convenient as an AJAX request.

The DNS option you are thinking of is probably one of the DNS poisoning attacks, or something similar, that can be used to enable cross-domain scripting for nefarious purposes if certain security patches are not applied.

There is the HTML5 postMessage method which can be used to get script from different locations talking together, but not all common browsers support this yet so you are reducing your potential target audience if you rely on the feature.

share|improve this answer

Look into setting the document.domain property in javascript. I know I've used it to allow javascript updates between windows across child domains ( and before. May work fine for Ajax too.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.