I am trying to use RequestBuilder to communicate with server using
AJAX (GWT 2.0).
Code is simple as possible:
public class Main implements EntryPoint {
public void onModuleLoad() {
RootPanel root = RootPanel.get();
Button button = new Button();
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
SendRequest();
}
});
root.add(button);
}
void SendRequest()
{
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
"http://127.0.01:8889/");
try {
Request request = builder.sendRequest(null, new
RequestCallback
() {
public void onError(Request request, Throwable
exception) {
Window.alert("OnError");
}
//@Override
public void onResponseReceived(Request request, Response
response) {
if (200 == response.getStatusCode()) {
Window.alert(response.getText());
} else {
Window.alert("Response error: " +
response.getText());
}
}
});
} catch (RequestException e) {
Window.alert("Exception: " + e.getMessage());
}
}
}
Server return object in JSON Format.
It's ok if I start GWT application in IE(8).
But if I start app in FF(3.5.6) or Chrome(4.0.266.0) - I get strange
behavior:
response.getStatusCode() == 0
response.getText() == ""
response.getStatusText() == ""
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.