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

Might help

Sent from my iPhone

On Apr 13, 2013, at 8:36 PM, Robson Braga <[email protected]> wrote:

> I get it! The following line was missing:
> 
> var script = document.createElement("script");
> 
> My bad...
> 
> 
> Em sábado, 13 de abril de 2013 21h27min29s UTC-3, Robson Braga escreveu:
>> 
>> Hi folks,
>> 
>> I have a webservice that returns a JSONP. The URL of the webservice is this:
>> 
>> http://user:password@localhost:8080/project/api/[email protected]&callback=callback1
>> 
>> The result of that URL is this:
>> 
>> callback1({"personId":"1","email":"[email protected]","password":"5f4dcc3b5aa765d61d8327deb882cf99","personType":"1","documentNumber":"00000000191","fullName":"Name
>>  Middle Last","phone":"4130232076","mobile":"4191199614","active":"true"})
>> 
>> I'm writting a GWT form to retrieve this information from my webservice. I 
>> have the following function, copied from GWT Tutorial, to do that:
>> 
>>     public native static void getClientJson(String url, GwtTest handler) /*-{
>>         // [1] The script starts by setting up a <script> element. The src 
>> attribute points to the URL that will retrieve the JSON data wrapped in a 
>> callback function.
>>         script.setAttribute("src", url);
>>         script.setAttribute("type", "text/javascript");
>>     
>>         // [2] The callback function is defined on the browser's window 
>> object. It receives as an argument a JavaScript object which is the JSON 
>> data returned by the server.
>>         window[callback] = function(jsonObj) {
>>             // [3] The callback function passes the JSON data as a 
>> JavaScript object to the Java method, handleJsonResponse.
>>             
>> [email protected]::handleJsonResponse(Lcom/google/gwt/core/client/JavaScriptObject;)(jsonObj);
>>             window[callback + "done"] = true;
>>         }
>>     
>>         // [4] A timeout function is defined to check for an unresponsive 
>> server or network problem; it checks a flag to see if the JSON callback was 
>> ever called.
>>         setTimeout(function() {
>>             if (!window[callback + "done"]) {
>>                 
>> [email protected]::handleJsonResponse(Lcom/google/gwt/core/client/JavaScriptObject;)(null);
>>             }
>>     
>>              // [5] Before the timeout function completes, it removes the 
>> new <script> element and the callback function from window.
>>              document.body.removeChild(script);
>>              delete window[callback];
>>              delete window[callback + "done"];
>>         }, 1000);
>>         
>>         // [6] Finally call appendChild() to attach the dynamically-loaded 
>> <script> element to the HTML document body. This causes the web browser to 
>> download the JavaScript referenced by the src attribute.
>>         document.body.appendChild(script);
>>     }-*/;
>> 
>> The problem is that when I execute this function, I always get this error 
>> message:
>> 
>> (ReferenceError) 
>> @com.google.gwt.gwttest.client.GwtTest::getClientJson(Ljava/lang/String;Lcom/google/gwt/gwttest/client/GwtTest;)([string:
>>  
>> 'http://user:password@localhost:8080/project/api/[email protected]&callback=callback1',
>>  Java object: com.google.gwt.gwttest.client.GwtTest@8723626]): script is not 
>> defined
>> 
>> What am I doing wrong? When I past that URL on Chrome, or any other browser, 
>> it works just fine.
>> 
>> Thanks in advance.
> -- 
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to