Class Xhr


  • public class Xhr
    extends Object
    A Simpler way to use XMLHttpRequest. Copied from the GWT project to make get/post return the XmlHttpRequest
    Since:
    1.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  Xhr.Callback
      Notifies when an XHR successfully completes, or errors out.
    • Constructor Summary

      Constructors 
      Constructor Description
      Xhr()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.google.gwt.xhr.client.XMLHttpRequest get​(elemental.html.Window window, String url, Xhr.Callback callback)
      Send a GET request to the url and dispatch updates to the callback.
      static com.google.gwt.xhr.client.XMLHttpRequest get​(String url, Xhr.Callback callback)
      Send a GET request to the url and dispatch updates to the callback.
      static com.google.gwt.xhr.client.XMLHttpRequest head​(elemental.html.Window window, String url, Xhr.Callback callback)
      Send a HEAD request to the url and dispatch updates to the callback.
      static com.google.gwt.xhr.client.XMLHttpRequest head​(String url, Xhr.Callback callback)
      Send a HEAD request to the url and dispatch updates to the callback.
      static com.google.gwt.xhr.client.XMLHttpRequest post​(elemental.html.Window window, String url, String requestData, String contentType, Xhr.Callback callback)
      Send a POST request to the url and dispatch updates to the callback.
      static com.google.gwt.xhr.client.XMLHttpRequest post​(String url, String requestData, String contentType, Xhr.Callback callback)
      Send a POST request to the url and dispatch updates to the callback.
    • Constructor Detail

      • Xhr

        public Xhr()
    • Method Detail

      • get

        public static com.google.gwt.xhr.client.XMLHttpRequest get​(String url,
                                                                   Xhr.Callback callback)
        Send a GET request to the url and dispatch updates to the callback.
        Parameters:
        url - the URL
        callback - the callback to be notified
        Returns:
        a reference to the sent XmlHttpRequest
      • get

        public static com.google.gwt.xhr.client.XMLHttpRequest get​(elemental.html.Window window,
                                                                   String url,
                                                                   Xhr.Callback callback)
        Send a GET request to the url and dispatch updates to the callback.
        Parameters:
        window - the window object used to access the XMLHttpRequest constructor
        url - the URL
        callback - the callback to be notified
        Returns:
        a reference to the sent XmlHttpRequest
      • head

        public static com.google.gwt.xhr.client.XMLHttpRequest head​(String url,
                                                                    Xhr.Callback callback)
        Send a HEAD request to the url and dispatch updates to the callback.
        Parameters:
        url - the URL
        callback - the callback to be notified
        Returns:
        a reference to the sent XmlHttpRequest
      • head

        public static com.google.gwt.xhr.client.XMLHttpRequest head​(elemental.html.Window window,
                                                                    String url,
                                                                    Xhr.Callback callback)
        Send a HEAD request to the url and dispatch updates to the callback.
        Parameters:
        window - the window object used to access the XMLHttpRequest constructor
        url - the URL
        callback - the callback to be notified
        Returns:
        a reference to the sent XmlHttpRequest
      • post

        public static com.google.gwt.xhr.client.XMLHttpRequest post​(String url,
                                                                    String requestData,
                                                                    String contentType,
                                                                    Xhr.Callback callback)
        Send a POST request to the url and dispatch updates to the callback.
        Parameters:
        url - the URL
        requestData - the data to be passed to XMLHttpRequest.send
        contentType - a value for the Content-Type HTTP header
        callback - the callback to notify
        Returns:
        a reference to the sent XmlHttpRequest
      • post

        public static com.google.gwt.xhr.client.XMLHttpRequest post​(elemental.html.Window window,
                                                                    String url,
                                                                    String requestData,
                                                                    String contentType,
                                                                    Xhr.Callback callback)
        Send a POST request to the url and dispatch updates to the callback.
        Parameters:
        window - the window object used to access the XMLHttpRequest constructor
        url - the URL
        requestData - the data to be passed to XMLHttpRequest.send
        contentType - a value for the Content-Type HTTP header
        callback - the callback to notify
        Returns:
        a reference to the sent XmlHttpRequest