Source:
public static Promise ajax(Settings settings) { resolveSettings(settings); final Function onSuccess = settings.getSuccess(); if (onSuccess != null) { onSuccess.setElement(settings.getContext()); } final Function onError = settings.getError(); if (onError != null) { onError.setElement(settings.getContext()); } final String dataType = settings.getDataType(); Promise ret = null; if ("jsonp".equalsIgnoreCase(dataType)) { ret = GQ.getAjaxTransport().getJsonP(settings); } else if ("loadscript".equalsIgnoreCase(dataType)){ ret = GQ.getAjaxTransport().getLoadScript(settings); } else { ret = GQ.getAjaxTransport().getXhr(settings) .then(new Function() { public Object f(Object...args) { 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()); } 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(); } } return new Object[]{retData, "success", request, response}; } }, new Function() { public Object f(Object...args) { Throwable exception = arguments(0); Request request = getArgument(1, Request.class); String msg = String.valueOf(exception); return new Object[]{null, msg, request, null, exception}; } }); } if (onSuccess != null) { ret.done(onSuccess); } if (onError != null) { ret.fail(onError); } return ret; }

Target:
public static Promise ajax(Settings settings) { resolveSettings(settings); final Function onSuccess = settings.getSuccess(); if (onSuccess != null) { onSuccess.setElement(settings.getContext()); } final Function onError = settings.getError(); if (onError != null) { onError.setElement(settings.getContext()); } final String dataType = settings.getDataType(); Promise ret = null; if ("jsonp".equalsIgnoreCase(dataType)) { ret = GQ.getAjaxTransport().getJsonP(settings); } else if ("loadscript".equalsIgnoreCase(dataType)){ ret = GQ.getAjaxTransport().getLoadScript(settings); } else { ret = GQ.getAjaxTransport().getXhr(settings) .then(new Function() { public Object f(Object...args) { Response response = arguments(0); Request request = arguments(1); Object retData = response.getText(); 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(); } } } return new Object[]{retData, "success", request, response}; } }, new Function() { public Object f(Object...args) { Throwable exception = arguments(0); Request request = getArgument(1, Request.class); String msg = String.valueOf(exception); return new Object[]{null, msg, request, null, exception}; } }); } if (onSuccess != null) { ret.done(onSuccess); } if (onError != null) { ret.fail(onError); } return ret; }