views:

143

answers:

2

As its Javadocs suggest, the JsonpRequestBuilder can only send GET requests. I need to send POST requests using the same method (for cross domain requests using JSON). Does anybody know any working solution? I could not find any starting point on the web.

thanks in advance

+1  A: 

You can't use JSONP to do a POST - all it does is inserting a <script src="..."> tag, and the browser fires off a GET request.

Maybe what you're looking for is CORS, but that's only supported by FF 3.5, IE 8 and Safari 4 and newer. And the server must support it, too.

Otherwise, you'll have to proxy from your server to the other domain.

Chris Lercher
thanks, your suggestions look promising. but due to limited time to this task, I have decided to keep using GET for now.
adranale
You forgot to mention Chrome 3 or newer. In case it helps, I've updated the CORS Wikipedia article with more detailed information on browser support that I gathered a few days ago.
ssokolow
+1  A: 

The Google APIs Library for GWT solves this problem (to send cross-domain GWT-RPC calls) by using the Shindig project's gadgets.rpc functionality to send a cross-frame message to an iframe in the page pointing to a page on the server you're trying to communicate with. That iframe is the one that makes the request, and when it receives a response, it sends another cross-frame message back.

This is wrapped up in GadgetsRequestBuilder.

It should be fairly straightforward to extend this functionality to make regular XHR requests (with a POST method) instead of GWT-RPC requests.

Jason Hall
thanks for your suggest, but due to limited time to this task, I have decided to keep using GET for now.
adranale