0

I want to make an AJAX call from www.mysite.com to api.mysite.com. Is this possible?

I've ready about document.domain, but as far as I can tell thats only good for cross DOM communication, such as through an iframe.

I'm also aware of CORS but am looking for a subdomain-specific solution, if there is one.

I looked at other questions before asking here and the only solutions I found were CORS (which I prefer not to use as the solutions I found for NGINx to do his were marked experimental) and proxies, which I don't want either for server load reasons.

Is there a way to do this?

Thanks

Che Kofif
  • 831
  • 1
  • 8
  • 22
  • My first thought, without writing any code, is this should be possible since it is a sub-domain. Have you tried this and gotten errors? – Zoidberg Feb 28 '12 at 14:01
  • See http://stackoverflow.com/a/7736250/27862 and http://stackoverflow.com/q/3076414/27862 – user123444555621 Feb 28 '12 at 14:18
  • Sorry, I wasn't clear. I've updated the question: I looked at other questions before asking here and the only solutions I found were CORS (which I prefer not to use as the solutions I found for NGINx to do his were marked experimental) and proxies, which I don't want either for server load reasons. – Che Kofif Feb 28 '12 at 14:29

1 Answers1

0

Here is almost the same question. You have three options:

  1. iframe + document.domain (see link above for details)
  2. set up proxy to redirect all request from www.mysite.com/api to api.mysite.com (to avoid cross-domain (or subdomain) issue completely)
  3. use jsonp
Community
  • 1
  • 1
Roman Bataev
  • 9,287
  • 2
  • 21
  • 15
  • Thanks, but I need another solution if possible. An iFraem is very messy and problematic, the proxy is a problem due to server load reasons and jsonp doesn't solve my need for POST. – Che Kofif Feb 28 '12 at 14:29