aboutsummaryrefslogtreecommitdiffstats
path: root/gwtquery-core
diff options
context:
space:
mode:
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2012-11-05 11:48:12 +0100
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2012-11-05 11:48:12 +0100
commit6bcd12d641198fa5f01136f8a957c8768761f837 (patch)
tree3d67329eea7be94d0c687b1b8c4dd5977927c2cb /gwtquery-core
parentcdc43cb866c21a3b9b78c16102723479becfdc07 (diff)
downloadgwtquery-6bcd12d641198fa5f01136f8a957c8768761f837.tar.gz
gwtquery-6bcd12d641198fa5f01136f8a957c8768761f837.zip
Ajax should handle statusCode == 0 as an error
Diffstat (limited to 'gwtquery-core')
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java
index 64e713db..832fda8b 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java
@@ -117,7 +117,7 @@ public class Ajax extends GQuery {
Method httpMethod = resolveHttpMethod(settings);
String data = resolveData(settings, httpMethod);
- String url = resolveUrl(settings, httpMethod, data);
+ final String url = resolveUrl(settings, httpMethod, data);
final String dataType = settings.getDataType();
if ("jsonp".equalsIgnoreCase(dataType)) {
@@ -135,7 +135,12 @@ public class Ajax extends GQuery {
}
public void onResponseReceived(Request request, Response response) {
- if (response.getStatusCode() >= 400) {
+ int statusCode = response.getStatusCode();
+ if (statusCode <= 0 || statusCode >= 400) {
+ if (statusCode == 0) {
+ // Just warn the developer about the status code
+ GWT.log("GQuery.ajax error, the response.statusCode is 0, this usually happens when you try to access an external server without CORS enabled. url=" + url);
+ }
if (onError != null) {
onError.fe(response.getText(), "error", request, response);
}