9

Is there a way without using a server proxy to perform a cross domain GET or POST request?

2
  • 8
    jsonp - ajaxian.com/archives/jsonp-json-with-padding Commented Jul 7, 2010 at 23:24
  • I should have clarified that my GET request's response is not JSON formatted, so I don't think $.getJSON works Commented Jul 7, 2010 at 23:29

5 Answers 5

13

If you are with only the current day browsers and have control over the external domain, you can use Cross-Origin Resource Sharing [CORS]

Most people do not have that luxury so you either have to use JSON with Padding [JSONP] or you need to use a serverside proxy.

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

1 Comment

Excellent answer. More info is available at this stack-o question; and also, check this blog post out; in addition, this mozilla-developer-network article is excellent reading, with links to more resources. edit: Note that in order to enable CORS, the server-side script must reply with special headers.
1

As far as I know, there is no way to make a cross-domain request in JS, but you could just query your server and make the request from there.

Edit: as Russ Cam said above, look into JSONP.

Comments

0

Using YQL is an easy way of doing cross domain ajax. You can specify to have a JSON or XML object returned. IBM has a good tutorial: http://www.ibm.com/developerworks/web/library/wa-aj-jsonp2/index.html

Though just search for yql cross domain and it'll bring up numerous tutorials.

Comments

0

You could use Flash. Flash allows you to make a cross-domain request to another server provided that it serves a Flash cross-domain policy file (an XML file). So you will need administrative access to the other server in order to set that up.

If you think this option might be what you're looking for or you want to do SSL/TLS cross-domain, check out the opensource Forge project:

http://github.com/digitalbazaar/forge/blob/master/README

Comments

-2

AJAX Cross Domain is a low-cost library that allows to perform cross-domain AJAX requests. http://www.ajax-cross-domain.com/

3 Comments

It would be great if the down-voters left comments so the public could be educated as to why this is a bad answer.
Yeah, please let me know as I've used this library in a couple of projects and haven't faced any issues.
It uses a 3rd party service which is usually not ideal.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.