aboutsummaryrefslogtreecommitdiffstats
path: root/gwtquery-core
diff options
context:
space:
mode:
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);
}