JsonpRequestBuilder requestString() - does it work?

82 views
Skip to first unread message

markww

unread,
Nov 25, 2012, 10:18:05 PM11/25/12
to google-we...@googlegroups.com
Hi,

I've got an example of JsonpRequestBuilder.send() working - but this requires us to provide an overlay type in the callback:

    new AsyncCallback<MyOverlayType>() {
        public void onSuccess(MyOverlayType result) {
        }
    }

Is there a way to instead get the raw String result from the remote server, before it gets translated into a JSON object? Something like:

    new AsyncCallback<String>() {
        public void onSuccess(String result) {
            println("Raw response from remote server is: " + result);
        }
    }

I thought maybe:

    JsonpRequestBuilder.requestString();

might do that, but doesn't seem to. In firefox, I get an error when trying that approach:

    uncaught exception: java.lang.ClassCastException
        null.a();

Thanks

Thomas Broyer

unread,
Nov 26, 2012, 2:16:07 AM11/26/12
to google-we...@googlegroups.com

On Monday, November 26, 2012 4:18:05 AM UTC+1, markww wrote:
Hi,

I've got an example of JsonpRequestBuilder.send() working - but this requires us to provide an overlay type in the callback:

    new AsyncCallback<MyOverlayType>() {
        public void onSuccess(MyOverlayType result) {
        }
    }

Is there a way to instead get the raw String result from the remote server, before it gets translated into a JSON object?

No.
The server sends back JavaScript that gets executed in the browser. There's no JSON in JSON-P, it's a JS object literal passed as argument to a JS function.
 
Something like:

    new AsyncCallback<String>() {
        public void onSuccess(String result) {
            println("Raw response from remote server is: " + result);
        }
    }

I thought maybe:

    JsonpRequestBuilder.requestString();

might do that, but doesn't seem to.

requestString() is for cases when the server responds with "callback('the string')"
Reply all
Reply to author
Forward
0 new messages