com.google.gwt.xhr.client.XMLHttpRequest.abort()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中com.google.gwt.xhr.client.XMLHttpRequest.abort()方法的一些代码示例,展示了XMLHttpRequest.abort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLHttpRequest.abort()方法的具体详情如下:
包路径:com.google.gwt.xhr.client.XMLHttpRequest
类名称:XMLHttpRequest
方法名:abort

XMLHttpRequest.abort介绍

[英]Aborts the current request.

See http://www.w3.org/TR/XMLHttpRequest/#the-abort-method.
[中]中止当前请求。
http://www.w3.org/TR/XMLHttpRequest/#the-abort-method

代码示例

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Cancels a pending request. If the request has already been canceled or if
 * it has timed out no action is taken.
 */
public void cancel() {
 if (xmlHttpRequest == null) {
  return;
 }
 timer.cancel();
 /*
  * There is a strange race condition that occurs on Mozilla when you cancel
  * a request while the response is coming in. It appears that in some cases
  * the onreadystatechange handler is still called after the handler function
  * has been deleted and during the call to XmlHttpRequest.abort(). So we
  * null the xmlHttpRequest here and that will prevent the
  * fireOnResponseReceived method from calling the callback function.
  * 
  * Setting the onreadystatechange handler to null gives us the correct
  * behavior in Mozilla but crashes IE. That is why we have chosen to fixed
  * this in Java by nulling out our reference to the XmlHttpRequest object.
  */
 final XMLHttpRequest xhr = xmlHttpRequest;
 xmlHttpRequest = null;
 xhr.clearOnReadyStateChange();
 xhr.abort();
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

/**
 * Cancels a pending request. If the request has already been canceled or if
 * it has timed out no action is taken.
 */
public void cancel() {
 if (xmlHttpRequest == null) {
  return;
 }
 timer.cancel();
 /*
  * There is a strange race condition that occurs on Mozilla when you cancel
  * a request while the response is coming in. It appears that in some cases
  * the onreadystatechange handler is still called after the handler function
  * has been deleted and during the call to XmlHttpRequest.abort(). So we
  * null the xmlHttpRequest here and that will prevent the
  * fireOnResponseReceived method from calling the callback function.
  * 
  * Setting the onreadystatechange handler to null gives us the correct
  * behavior in Mozilla but crashes IE. That is why we have chosen to fixed
  * this in Java by nulling out our reference to the XmlHttpRequest object.
  */
 final XMLHttpRequest xhr = xmlHttpRequest;
 xmlHttpRequest = null;
 xhr.clearOnReadyStateChange();
 xhr.abort();
}

代码示例来源:origin: net.wetheinter/gwt-user

/**
 * Cancels a pending request. If the request has already been canceled or if
 * it has timed out no action is taken.
 */
public void cancel() {
 if (xmlHttpRequest == null) {
  return;
 }
 timer.cancel();
 /*
  * There is a strange race condition that occurs on Mozilla when you cancel
  * a request while the response is coming in. It appears that in some cases
  * the onreadystatechange handler is still called after the handler function
  * has been deleted and during the call to XmlHttpRequest.abort(). So we
  * null the xmlHttpRequest here and that will prevent the
  * fireOnResponseReceived method from calling the callback function.
  * 
  * Setting the onreadystatechange handler to null gives us the correct
  * behavior in Mozilla but crashes IE. That is why we have chosen to fixed
  * this in Java by nulling out our reference to the XmlHttpRequest object.
  */
 final XMLHttpRequest xhr = xmlHttpRequest;
 xmlHttpRequest = null;
 xhr.clearOnReadyStateChange();
 xhr.abort();
}

代码示例来源:origin: io.reinert.requestor.core/requestor-api

/**
 * Cancels a pending request. If the request has already been canceled or if
 * it has timed out no action is taken.
 */
public void cancel() {
  if (xmlHttpRequest == null) {
    return;
  }
  timer.cancel();
/*
 * There is a strange race condition that occurs on Mozilla when you cancel
 * a request while the response is coming in. It appears that in some cases
 * the onreadystatechange handler is still called after the handler function
 * has been deleted and during the call to XmlHttpRequest.abort(). So we
 * null the xmlHttpRequest here and that will prevent the
 * fireOnResponseReceived method from calling the callback function.
 * 
 * Setting the onreadystatechange handler to null gives us the correct
 * behavior in Mozilla but crashes IE. That is why we have chosen to fixed
 * this in Java by nulling out our reference to the XmlHttpRequest object.
 */
  final XMLHttpRequest xhr = xmlHttpRequest;
  xmlHttpRequest = null;
  xhr.clearOnReadyStateChange();
  xhr.abort();
}

代码示例来源:origin: org.atmosphere/atmosphere-gwt-client

@Override
  public void run() {
    r.clearOnReadyStateChange();
    if (r.getReadyState() != XMLHttpRequest.DONE
        && r.getReadyState() != XMLHttpRequest.UNSENT) {
      listener.onDisconnected();
      r.abort();
    }
    r = null;
  }
}.schedule(5000);

代码示例来源:origin: com.vaadin.external.atmosphere/atmosphere-gwt-client

@Override
  public void run() {
    r.clearOnReadyStateChange();
    if (r.getReadyState() != XMLHttpRequest.DONE
        && r.getReadyState() != XMLHttpRequest.UNSENT) {
      listener.onDisconnected();
      r.abort();
    }
    r = null;
  }
}.schedule(5000);

代码示例来源:origin: org.atmosphere/atmosphere-gwt-client

if (xmlHttpRequest.getReadyState() != XMLHttpRequest.DONE) {
  listener.onDisconnected();
  xmlHttpRequest.abort();

代码示例来源:origin: com.vaadin.external.atmosphere/atmosphere-gwt-client

if (xmlHttpRequest.getReadyState() != XMLHttpRequest.DONE) {
  listener.onDisconnected();
  xmlHttpRequest.abort();

代码示例来源:origin: com.vaadin.external.atmosphere/atmosphere-gwt-client

@Override
  public void onReadyStateChange(XMLHttpRequest request) {
    if (!aborted) {
      switch (request.getReadyState()) {
        case XMLHttpRequest.LOADING:
          onReceiving(request.getStatus(), request.getResponseText());
          if (needPolling()) {
            pollingTimer.scheduleRepeating(POLLING_INTERVAL);
          }
          break;
        case XMLHttpRequest.DONE:
          onLoaded(request.getStatus(), request.getResponseText());
          pollingTimer.cancel();
          break;
      }
    } else {
      request.clearOnReadyStateChange();
      if (request.getReadyState() != XMLHttpRequest.DONE) {
        request.abort();
      }
    }
  }
});

代码示例来源:origin: org.atmosphere/atmosphere-gwt-client

@Override
  public void onReadyStateChange(XMLHttpRequest request) {
    if (!aborted) {
      switch (request.getReadyState()) {
        case XMLHttpRequest.LOADING:
          onReceiving(request.getStatus(), request.getResponseText());
          if (needPolling()) {
            pollingTimer.scheduleRepeating(POLLING_INTERVAL);
          }
          break;
        case XMLHttpRequest.DONE:
          onLoaded(request.getStatus(), request.getResponseText());
          pollingTimer.cancel();
          break;
      }
    } else {
      request.clearOnReadyStateChange();
      if (request.getReadyState() != XMLHttpRequest.DONE) {
        request.abort();
      }
    }
  }
});

代码示例来源:origin: org.atmosphere/atmosphere-gwt-client

} catch (JavaScriptException e) {
  if (xmlHttpRequest != null) {
    xmlHttpRequest.abort();
    xmlHttpRequest = null;

代码示例来源:origin: com.vaadin.external.atmosphere/atmosphere-gwt-client

} catch (JavaScriptException e) {
  if (xmlHttpRequest != null) {
    xmlHttpRequest.abort();
    xmlHttpRequest = null;

相关文章