Tuesday, September 7, 2010

Re: Cross Site Requests for JSON : Invalid Label

In other words you are using JSONP client code to hit a JSON service.
Without more info I am assuming this is your problem. In order to
make cross site requests using the method described on the page you
referenced you service needs to output JSONP, that is wrapping the
JSON with a call to the specified function; i.e. /test?
callback=testFunction would return
testFunction({"testAttribute":"testStringValue"}). Also, since 2.0
the JsonpRequestBuilder class is provided and you don't have to go
through as much trouble as you did in 1.6, which is what the referred
article is targeting.

http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/jsonp/client/JsonpRequestBuilder.html

> I had a search for solutions and all I could find was things about
> adding parenthesis around the json string in the eval function.
>
> I do not use the eval function and the json is not a string - it is a
> JavaScriptObject.

This is true if you would like to use JSON directly if you are not
making a cross-site request. you will sometimes need to wrap the JSON
returned by the service with "{"+jaonText+"}" if you use request
builder, which will return a string then you will have to make a
native method to call eval to translate that string into a javascript
object, but if you are making a cross-site request then you must use
the JsonpRequestBuilder.

On Sep 7, 7:31 am, kudos <miss.michelle.dor...@googlemail.com> wrote:
> I have followed the steps here:http://code.google.com/webtoolkit/doc/1.6/tutorial/Xsite.html
> to create a call to another server for JSON data.
>
> Firebug shows an "invalid label" error when i run the application.
>
> I had a search for solutions and all I could find was things about
> adding parenthesis around the json string in the eval function.
>
> I do not use the eval function and the json is not a string - it is a
> JavaScriptObject.
>
> Has anyone else found a solution to this?
>
> Thanks

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment