Crothers
Crothers

Reputation: 177

Cross Domain Get Request in JS/JQuery

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

Upvotes: 9

Views: 16357

Answers (5)

treeface
treeface

Reputation: 13351

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.

Upvotes: 1

dlongley
dlongley

Reputation: 2096

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

Upvotes: 0

Mark
Mark

Reputation: 3197

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.

Upvotes: 0

epascarello
epascarello

Reputation: 207557

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.

Upvotes: 13

Ivan
Ivan

Reputation: 1561

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

Upvotes: -2

Related Questions