From 5430b6bbe29fc6e5ac7e1ba2e3709e7731b2db2c Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Tue, 4 Mar 2014 13:38:26 +0100 Subject: Exception when parsing empty response.getText(), and the dataType is necessary for the request. --- .../src/main/java/com/google/gwt/query/client/plugins/ajax/Ajax.java | 3 +++ 1 file changed, 3 insertions(+) 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 e11e5923..e98749ae 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 @@ -145,6 +145,9 @@ public class Ajax extends GQuery { Response response = arguments(0); Request request = arguments(1); Object retData = response.getText(); + if (response.getText() == null || response.getText().isEmpty()) { + return new Object[]{response.getText(), "success", request, response}; + } try { if ("xml".equalsIgnoreCase(dataType)) { retData = JsUtils.parseXML(response.getText()); -- cgit v1.2.3 From feb7f50a21f7f7b95ca067c6fcf4ec01524715f3 Mon Sep 17 00:00:00 2001 From: Adolfo Panizo Date: Tue, 4 Mar 2014 13:38:26 +0100 Subject: Exception when parsing empty response.getText(), and the dataType is necessary for the request. --- .../google/gwt/query/client/plugins/ajax/Ajax.java | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 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 e11e5923..b0ee21ad 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 @@ -145,22 +145,24 @@ public class Ajax extends GQuery { Response response = arguments(0); Request request = arguments(1); Object retData = response.getText(); - try { - if ("xml".equalsIgnoreCase(dataType)) { - retData = JsUtils.parseXML(response.getText()); - } else if ("json".equalsIgnoreCase(dataType)) { - retData = GQ.create(response.getText()); - } else { - retData = response.getText(); - if ("script".equalsIgnoreCase(dataType)) { - ScriptInjector.fromString((String)retData).setWindow(window).inject(); + if (retData != null && !"".equals(retData)) { + try { + if ("xml".equalsIgnoreCase(dataType)) { + retData = JsUtils.parseXML(response.getText()); + } else if ("json".equalsIgnoreCase(dataType)) { + retData = GQ.create(response.getText()); + } else { + retData = response.getText(); + if ("script".equalsIgnoreCase(dataType)) { + ScriptInjector.fromString((String)retData).setWindow(window).inject(); + } + } + } catch (Exception e) { + if (GWT.isClient() && GWT.getUncaughtExceptionHandler() != null) { + GWT.getUncaughtExceptionHandler().onUncaughtException(e); + } else { + e.printStackTrace(); } - } - } catch (Exception e) { - if (GWT.isClient() && GWT.getUncaughtExceptionHandler() != null) { - GWT.getUncaughtExceptionHandler().onUncaughtException(e); - } else { - e.printStackTrace(); } } return new Object[]{retData, "success", request, response}; -- cgit v1.2.3