private static void request( XMLHttpRequest xhr, String method, String url, final XhrCallback callback) { try { xhr.setOnReadyStateChange(new Handler(callback)); xhr.open(method, url); xhr.send(); } catch (Exception e) { // Just fail. callback.onFail(xhr); xhr.clearOnReadyStateChange(); } }
private static void request( XMLHttpRequest xhr, String method, String url, String requestData, String contentType, XhrCallback callback) { try { xhr.setOnReadyStateChange(new Handler(callback)); xhr.open(method, url); xhr.setRequestHeader("Content-type", contentType); xhr.send(requestData); } catch (Exception e) { // Just fail. callback.onFail(xhr); xhr.clearOnReadyStateChange(); } }