Namespace: server

mx. server

Handle server communication.

Methods

(static) get(args)

Fetches a resource from the server using the HTTP GET method.

Parameters:
Name Type Description
args Object
Properties
Name Type Description
url string

url from which to fetch the resource

handleAs "text" | "json" | "xml"

format in which to deliver the response

load mx.server~XhrSuccessCallback

function to handle the response

error mx.server~XhrErrorCallback

function to handle errors

Deprecated:
  • since version 8.0.0, use the Fetch API instead
Example
mx.server.get({
    url: "/data/files/dogs.txt",
    handleAs: "text",
    load: function(response) {
        console.log("dogs", response);
    },
    error: function(e) {
        console.log("failed to retrieve resource");
    }
});

(static) getCacheBust() → {string}

Gets the cache bust used to refetch assets after a redeployment.

Returns:

cache bust to append to an URL

Type
string
Example
mx.server.getCacheBust(); // Get the cache bust e.g. "635161595264900996"

Type Definitions

XhrErrorCallback(error)

Error callback for XHRs.

Parameters:
Name Type Description
error Error

error describing the failure of the request

XhrSuccessCallback(response)

Success callback for XHRs.

Parameters:
Name Type Description
response string | object | Document

response for the XHR, depending on the args.handleAs parameter of the original request