Ajax

Ajax

Ajax helper class

options.binaryRequestData should be of the format:
{ 'ref' => { 'url' : "optionalFullOverrideURL", "headers" => { "headerKey" : "HeaderValue"}}

Constructor

new Ajax(rootPath, options)

Parameters:
Name Type Description
rootPath string
options Object
Properties
Name Type Description
binaryRequestData Object

object where keys are refs for which to optionally override the URL and/or request headers.

Members

(static) crossOrigin

Allow cross-origin requests (CORS) for images.

Methods

_loadImage(url) → {Promise}

Loads image data at specified path which is returned in a Promise object.

Parameters:
Name Type Description
url string

Path to whatever shall be loaded.

Example
loader._loadImage('resources/image.png').then(function (image) {
  // handle Image image
});

_loadVideo(url, mimeType) → {Promise}

Loads video data at specified path which is returned in a Promise object.

Parameters:
Name Type Description
url string

Path to whatever shall be loaded.

mimeType string

the mimeType of the video to load

Example
loader._loadVideo('resources/vid.webm').then(function (video) {
  // handle Video video
});

clear()

Clears the ajax cache
Is called by DynamicLoader.clear

get(options) → {Promise}

Uses GET to retrieve data at a remote location.

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

The full URL to GET. The rootpath should be included.(You should probably be using ajax.load())

responseType string

The XHR response type. This is set directly on the XMLHttpRequest object

load(path, reloadopt) → {Promise}

Loads data at specified path which is returned in a Promise object.

Parameters:
Name Type Attributes Default Description
path string

Path to whatever shall be loaded.

reload boolean <optional>
false

If set to true, reloads even if url is cached

prefill(bundle, clearopt)

Prefill ajax cache with data

Parameters:
Name Type Attributes Default Description
bundle Object

Pairs of key-configs

clear boolean <optional>
false

If set to true will overwrite cache, otherwise extend it