Class: Ajax

Ajax(url, properties)

Defines the AjaxConnector to connect to a remote server by making AjaxRequest.

Constructor

new Ajax(url, properties)

Creates Ajax.
Parameters:
Name Type Description
url String -
properties Object -
Properties
Name Type Description
method String -
responseType String -
Source:
Example
import Ajax from 'core/protocol/Ajax.js';

let request = ...;
let protocol = new Ajax(url);

// handle onSuccess
protocol.onSuccess = function(event) {
 // does something
}

protocol.onError = function(event) {
 // does something
}

// send request
protocol.sendRequest(request);

Extends

Methods

checkStatus(status)

Check a change of the status and call the corresponding callbacks if necessary
Parameters:
Name Type Description
status Status the currentStatus
Overrides:
Source:

getId() → {String}

The data protocol default id.
Overrides:
Source:
Returns:
Type
String

getUrl() → {String}

The stream url.
Overrides:
Source:
Returns:
Type
String

onChangeStatus(status)

Called when the connection STATUS changes
Parameters:
Name Type Description
status Status the new status
Overrides:
Source:

onConnect()

Called when the protocol has been connected
Overrides:
Source:

onDisconnect()

Called when the protocol has been disconnected
Overrides:
Source:

sendRequest(request, extraUrl)

Sends the request to the defined server.
Parameters:
Name Type Description
request String The Http request
extraUrl String get query parameters
Source:

setReconnectTimeout(timeout)

Sets the reconnection timeout
Parameters:
Name Type Description
timeout Number delay in milliseconds before reconnecting dataSource
Overrides:
Source:

setUrl(url)

Sets the url
Parameters:
Name Type Description
url
Overrides:
Source:

Events

onError

This is the callback method in case of getting error connection.
Parameters:
Name Type Description
event The error details
Source:

onSuccess

This is the callback method in case of getting success connection.
Parameters:
Name Type Description
event
Source: