JsonpRequestBuilder jsonprb= new JsonpRequestBuilder();
jsonprb.requestObject("http://localhost:8084/XXX/GWTServlet",
new AsyncCallback() {
@Override
public void onFailure(Throwable caught) {
Window.alert("Failure getting JSONP directly from remote server");
}
@Override
public void onSuccess(Object result) {
Window.alert("Got response");
JavaScriptObject res = (JavaScriptObject) result;
Window.alert(res.toSource());
}
});
public void onClick(ClickEvent event) {
JsonpRequestBuilder jsonprb= new JsonpRequestBuilder();
jsonprb.requestString("http://localhost:8084/Arahant/GWTServlet",
new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
Window.alert("Failure getting JSONP directly from remote server");
}
@Override
public void onSuccess(String result) {
Window.alert("Got " + result);
}
});
Server:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String callback = request.getParameter("callback");
PrintWriter out = response.getWriter();
try {
out.print(callback + "(\"Hello there\")");
} finally {
out.close();
}
}
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/-r5aW6rcfGMJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.