Saturday, November 30, 2013

Re: JsonpRequestBuilder only works across domains?



On Friday, November 29, 2013 9:17:18 PM UTC+1, Magier Marantis wrote:

Am Dienstag, 26. Januar 2010 18:54:43 UTC+1 schrieb Thomas Broyer:

On Jan 26, 12:43 pm, "m.mil...@newelements.de"
<m.mil...@newelements.de> wrote:
> once again, i have to answer the question myself!
> at first: would anyone PLEASE write an guide for using the
> jsonprequestbuilder!!!! it´s damn annoing the find out everything by
> try and error.
>
> about my problem:
> the name of the callback method for the jsonp request changes whith
> every request.
> when you do the first request the name is: __gwt_jsonp__.I0.onSuccess
> for the second request: __gwt_jsonp__.I1.onSuccess
> for the third: __gwt_jsonp__.I2.onSuccess
> ...
>
> that definetly make sense, BUT is nowhere noted in the
> documentation!!!!!
> and - belive it or not - you can see this little change from one
> request to another very hard when you look at a couple of requests.

The javadoc for JsonpRequestBuilder starts with:
"""The server will receive a request including a callback url
parameter, which should be used to return the response as following:

<callback>(<json>);

where <callback> is the url parameter (see setCallbackParam
(String)),"""

It's clear to me that the URL will contain a query string with a
parameter like "callback=fnName" (where 'callback' is the value you
passed to setCallbackParam, and 'fnName' is the <callback>, i.e. the
function name to "call").
It even comes with an example of calling a GData API (with a link to
the GData API documentation that explains what "?alt=json-in-script"
means)

Maybe you should first read some doc about JSON-P, such as
http://en.wikipedia.org/wiki/JSON#JSONP

@Thomas Broyer

Learn2Read!

I'll try, I promise.
 
--------------------------------------------------------------------------------------------

The javadoc for JsonpRequestBuilder starts with:
"""The server will receive a request including a callback url
parameter, which should be used to return the response as following:

<callback>(<json>);

where <callback> is the url parameter (see setCallbackParam
(String)),"""

--------------------------------------------------------------------------------------------

is here anything written, the callback function name has to start with "__gwt_jsonp__.I0.onSuccess"?!


There's nothing about it because there shouldn't be anything about it; it's an implementation detail that you don't need to know as a user of JsonpRequestBuilder, and the server doesn't need to bother about: it should just take the name passed in the URL, whichever it is.

 

In facts, the GWT functions "JsonRequestBuilder" and "RequestBuilder" does only work correctly if u'll use callback function names with the GOOGLE names/patterns!

Or in other words, everybody will say this both functions are incredible buggy just google means this is normal and a feature!


This BUG is described on www.inter-net.de (german), inclusive a gwt jsonp solution for all who dont like to use google function names!

I don't read German so I relied on Google Translate, but nowhere in this article is it explained why this is a problem.

They talk about "standard JSONP", so let's go read what Wikipedia has to say about it: http://en.wikipedia.org/wiki/JSONP

 By convention, the browser provides the name of the callback function as a named query parameter value, typically using the name jsonp or callback as the named query parameter field name, in its request to the server, e.g.,

<script type="application/javascript"          src="http://server2.example.com/Users/1234?jsonp=parseResponse">  </script>  

In this example, the received payload would be:

parseResponse({"Name": "Foo", "Id": 1234, "Rank": 7});

This is exactly what the javadoc says: using setCallbackParam you configure the name of the parameter ("callback", "jsonp" or whatever the server expects), GWT then chooses the value of that parameter and the server si expected to just take that value and use it in the response (when Wikipedia says "the browser provides", it means the JavaScript code; with JsonpRequestBuilder, GWT provides the value and you don't have to care about it).

Now explain to me how this is specific to Google and why this is a bug.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment