Class BTM.AJAX.Request
AJAX Request class
Defined in: ajax.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
BTM.AJAX.Request(url, callbacks, options)
|
| Field Attributes | Field Name and Description |
|---|---|
|
The custom response object for the Request
|
| Method Attributes | Method Name and Description |
|---|---|
|
Exposed event listener method to allow the onReadyStateChanged event to make calls to this Request
|
|
|
run()
Initiate the AJAX request.
|
Class Detail
BTM.AJAX.Request(url, callbacks, options)
- Parameters:
- {String} url
- the URL to request
- {Function|Function[]} callbacks
- Function(s) to call, either a single function to call on "Success", or an object containing Functions with keys representing the HTTP codes/status names and/or AJAX pseudo event names. If a HTTP status code is provided, the generic handler for the corresponding status type will not run.
- {Function} callbacks.onBeforeStart Optional
- Function to be called when the AJAX request is created (before the internal call to the open() Method)
- {Function} callbacks.onLoading Optional
- Function to be called when the AJAX request is started (after the internal call to the open() Method)
- {Function} callbacks.onLoaded Optional
- Function to be when the AJAX request has been sent, but before the response starts to download (after the internal call to the send() Method)
- {Function} callbacks.onInteractive Optional
- Function to be called when the AJAX request starts to download the response.
- {Function} callbacks.onComplete Optional
- Function to be called when the AJAX request has completed (after HTTP-status specific callbacks)
- {Function} callbacks.onSuccess Optional
- Function to be called when the AJAX request is sucessful (i.e. any of the HTTP 2xx codes)
- {Function} callbacks.onError Optional
- Function to be called when the AJAX request fails (i.e. any of the HTTP 4xx or 5xx codes)
- {Object} options Optional
- the options Object
- {String} options.method Optional, Default: 'POST'
- the HTTP method to use for the request, either 'POST' or 'GET'
- {Boolean} options.forceJSON Optional, Default: false
- force the responseText to be treated as JSON, ignoring content-type
- {Boolean} options.forceXML Optional, Default: false
- force the responseText to be treated as XML, ignoring content-type
- {Boolean} options.autoRun Optional, Default: true
- flag to make the XMLHttpRequest when the object is created
Field Detail
response
The custom response object for the Request
Method Detail
readyStateChanged()
Exposed event listener method to allow the onReadyStateChanged event to make calls to this Request
run()
Initiate the AJAX request. Normally runs automatically