response.getStatusCode()
I'm following https://developers.google.com/web-toolkit/doc/latest/DevGuideServerCommunication#DevGuideHttpRequests
I have
String url = "http://.../index.php";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
URL.encode(url));
try {
Request request = builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// Couldn't connect to server (could be timeout, SOP violation, etc.)
}
@Override
public void onResponseReceived(Request request, Response response) {
Window.alert("getStatusCode:" + response.getStatusCode());
if (200 == response.getStatusCode()) {
// Process the response in
// response.getText()
Window.alert("RESPONSE:" + response.getText());
} else {
// Handle the error. Can get the status
// text from response.getStatusText()
Window.alert("OTHER STATUS:" + response.getStatusText());
}
}
});
} catch (RequestException e) {
// Couldn't connect to server
}
I get an alert box from the above code "getStatusCode:0" although my
Apache2 access logs has code 200 when this code is hit.
(And then "OTHER STATUS:" with empty status text).
A comment in stackoverflow says, "We've found a status code of "0"
usually means the user navigated to a different page before the AJAX
call completed."
Going directly to the URL in a browser returns a test JSON string
[{"symbol":"ABC","price":40.485578668179,"change":-0.53944918844604},
{"symbol":"DEF","price":1.3606576154209,"change":0.0051755221198266}]
Please advise.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home