@maxgraph/core
    Preparing search index...

    Class MaxXmlRequest

    XML HTTP request wrapper. See also: mxUtils.get, mxUtils.post and mxUtils.load. This class provides a cross-browser abstraction for Ajax requests.

    For encoding parameter values, the built-in encodeURIComponent JavaScript method must be used. For automatic encoding of post data in Editor the Editor.escapePostData switch can be set to true (default). The encoding will be carried out using the conte type of the page. That is, the page containting the editor should contain a meta tag in the header, eg.

    var onload = function(req)
    {
    mxUtils.alert(req.getDocumentElement());
    }

    var onerror = function(req)
    {
    mxUtils.alert('Error');
    }
    new MaxXmlRequest(url, 'key=value').send(onload, onerror);

    Sends an asynchronous POST request to the specified URL.

    var req = new MaxXmlRequest(url, 'key=value', 'POST', false);
    req.send();
    mxUtils.alert(req.getDocumentElement());

    Sends a synchronous POST request to the specified URL.

    var encoder = new Codec();
    var result = encoder.encode(graph.getDataModel());
    var xml = encodeURIComponent(mxUtils.getXml(result));
    new MaxXmlRequest(url, 'xml='+xml).send();

    Sends an encoded graph model to the specified URL using xml as the parameter name. The parameter can then be retrieved in C# as follows:

    string xml = HttpUtility.UrlDecode(context.Request.Params["xml"]);
    

    Or in Java as follows:

    String xml = URLDecoder.decode(request.getParameter("xml"), "UTF-8").replace("
    ", "
");

    Note that the linefeeds should only be replaced if the XML is processed in Java, for example when creating an image.

    Index

    Constructors

    • Parameters

      • url: string
      • params: null | string = null
      • method: "GET" | "POST" = 'POST'
      • async: boolean = true
      • username: null | string = null
      • password: null | string = null

      Returns MaxXmlRequest

    Properties

    async: boolean

    Boolean indicating if the request is asynchronous.

    binary: boolean = false

    Boolean indicating if the request is binary. This option is ignored in IE. In all other browsers the requested mime type is set to text/plain; charset=x-user-defined. Default is false.

    false
    
    decodeSimulateValues: boolean = false

    Specifies if request values should be decoded as URIs before setting the textarea value in simulate. Defaults to false for backwards compatibility, to avoid another decode on the server this should be set to true.

    method: "GET" | "POST"

    Specifies the request method. Possible values are POST and GET. Default is POST.

    params: null | string

    Holds the form encoded data for the POST request.

    password: null | string

    Specifies the password to be used for authentication.

    request: any = null

    Holds the inner, browser-specific request object.

    url: string

    Holds the target URL of the request.

    username: null | string

    Specifies the username to be used for authentication.

    withCredentials: boolean = false

    Specifies if withCredentials should be used in HTML5-compliant browsers. Default is false.

    false
    

    Methods

    • Returns the document element of the response XML document.

      Returns null | HTMLElement

    • Returns the status as a number, e.g. 404 for "Not found" or 200 for "OK". Note: The NS_ERROR_NOT_AVAILABLE for invalid responses cannot be caught.

      Returns number

    • Send the request to the target URL using the specified functions to process the response asynchronously.

      Note: Due to technical limitations, onerror is currently ignored.

      Parameters

      • onload: null | Function = null

        Function to be invoked if a successful response was received.

      • onerror: null | Function = null

        Function to be called on any error. Unused in this implementation, intended for overridden function.

      • timeout: null | number = null

        Optional timeout in ms before calling ontimeout.

      • ontimeout: null | Function = null

        Optional function to execute on timeout.

      Returns void

    • Sets the headers for the given request and parameters. This sets the content-type to application/x-www-form-urlencoded if any params exist.

      Parameters

      • request: any
      • params: any

      Returns void

      request.setRequestHeaders = function(request, params)
      {
      if (params != null)
      {
      request.setRequestHeader('Content-Type',
      'multipart/form-data');
      request.setRequestHeader('Content-Length',
      params.length);
      }
      };

      Use the code above before calling send if you require a multipart/form-data request.

    • Creates and posts a request to the given target URL using a dynamically created form inside the given document.

      Parameters

      • doc: any

        Document that contains the form element.

      • target: null | string = null

        Target to send the form result to.

      Returns void