PDA

View Full Version : Hack for POSTing data cross-domain (JSONP-like)



Steffen Hiller
16 Feb 2011, 6:45 AM
Just wondering if anybody here already has used a hack for POSTing data cross-domain?
Apparently there's a hack to do that through a hidden iframe, but I didn't investigate/try it yet.

Anyone with experience out there?

Thanks.

steve1964
16 Feb 2011, 9:34 AM
Hi, you can use a server side proxy, so you post on same domain. If you use php server side:


<?php
readfile($_REQUEST["url"]);
?>

Where url is your cross domain request

Steffen Hiller
16 Feb 2011, 9:44 AM
Hmm, wanted a JavaScript-only solution, but yeah, thanks for reminding me of that solution.
readfile wouldn't do a post request though, but I get your idea.
Thanks!

steve1964
16 Feb 2011, 10:02 AM
Hi Steffen, the above was just a sample, if you need an out of the box php server side solution to make cross domain post request take a look here:
http://benalman.com/projects/php-simple-proxy/

joelnet
16 Feb 2011, 4:18 PM
You can implement a fully javascript cross-domain data solution using YQL

http://developer.yahoo.com/yql/

oyvind.kinsey
22 Feb 2011, 9:27 AM
If you use easyXDM (http://easyxdm.net)you can both post (as shown in this example here (http://consumer.easyxdm.net/current/example/upload.html)) do Cross-Domain xhr or plain Cross-Domain Messaging. See the entire suit of examples here (http://consumer.easyxdm.net/current/example/upload.html), or read the README at github (github.com/oyvindkinsey/easyXDM#readme).