I am writing an application in GWT that is supposed to get the JSON from external server. I am using JsonpRequestBuilder
but I always get failures (timeouts) since this is a JSON no JSONP.
If I would have my own server then I would be able to change the response format (to JSONP).
What can I change to get it working ?
I have checked it with Google Chrome's debugger and I do! get the response but somehow code falls into the onFailure
method and I can't use the response.
String url = "http://api.mobile.endomondo.com/mobile/api/workout/list?authToken=XXXX";
JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
jsonp.setTimeout(100000);
jsonp.setCallbackParam("callback");
jsonp.requestObject(url,
new AsyncCallback<TrainingData>() { // Type-safe!
@Override
public void onFailure(Throwable throwable) {
// Easy to debug! (hopefully)
Window.alert(throwable.getMessage());
}
@Override
public void onSuccess(TrainingData trd) {
// Success!
//Window.alert("JSON obtained");
Window.alert(trd.getEntries().toString());
}
});
EDIT Now I cam getting
Cross-site hosted mode not yet implemented. See issue http://code.google.com/p/google-web-toolkit/issues/detail?id=2079