Share Coding

Tutorials, Problems, Stuffs …

Cross Domain Request on GWT without RPC

Since RequestBuilder do not support cross domain on GWT, the other option will be JsonpRequestBuilder
Here is an example between client and server (PHP).

JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
jsonp.requestObject(URL.encode("http://serverurl/Server.php?callback=test_clbk"), new AsyncCallback() {
	public void onFailure(Throwable throwable) {
	public void onSuccess(JSONreceiver result) {

public class JSONreceiver extends JavaScriptObject {
	protected JSONreceiver() {}
	public final native String getResult() /*-{
	    return this.result;


	$callback = $_GET['callback'];
	echo "$callback({result: 'Message from Server.php'});";

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: