0

I know Stackoverflow is full of this question, but...

How to make cross-domain AJAX request?

I do not want to use

  • Proxy server
  • Access-Control-Allow-Origin doesn't work
  • jQuery.getJSON()
  • jQuery.load()
  • jQuery.get()

because, I also need to send headers

X-API-Version = DEV 

Thanks for reply!

5
  • Using a proxy does not exclude setting custom HTTP headers. Commented Nov 24, 2010 at 22:12
  • What do you mean by "Access-Control-Allow-Origin doesn't work"? Commented Nov 24, 2010 at 22:19
  • I am calling from localhost and server 127.0.0.1 is responding with Access-Control-Allow-Origin = *. Commented Nov 24, 2010 at 22:24
  • It sounds like your real question is "How do I get Access-Control-Allow-Origin to work?" I suggest you ask that question with more details of what you've tried. Commented Nov 24, 2010 at 22:37
  • It sounds like you want sub-domain XMLHttpRequest. Have you looked at fettig.net/weblog/2005/11/30/xmlhttprequest-subdomain-update ? Commented Nov 26, 2010 at 3:29

1 Answer 1

8

You can't do this, not if you exclude the methods above. Cross-domain requests (if you want to see content) can only be made with JSONP or a proxy server...and you can't set headers with JSONP.

Sign up to request clarification or add additional context in comments.

7 Comments

Even if I'm sending AJAX request to subdomain?
So how does Twitter work? It sends requests to subdomain with custom headers.
@Ryan - show me an example of this? the request is likely not behaving like you think
@Ryan - both of those examples aren't cross-domain, if you see the referrer those are requests made to the same domain (www.facebook.com -> www.facebook.com and api.twitter.com/p_receiver.html -> api.twitter.com/1/users...), and are XmlHttpRequests, not JSONP.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.