Ejemplo n.º 1
0
 public void onReadyStateChange(XMLHttpRequest xhr) {
   if (xhr.getReadyState() == XMLHttpRequest.DONE) {
     if (xhr.getStatus() == 200) {
       callback.onSuccess(xhr);
       xhr.clearOnReadyStateChange();
       return;
     }
     callback.onFail(xhr);
     xhr.clearOnReadyStateChange();
   }
 }
Ejemplo n.º 2
0
 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();
   }
 }
Ejemplo n.º 3
0
 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();
   }
 }