Class BTM.AJAX.Updater
Extends
BTM.AJAX.Request.
Special-use class to update an Element with the response of an AJAX request. After the update is performed, all Mappings BTM.Mapping are re-run for the target element
Defined in: ajax.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
BTM.AJAX.Updater(selector, url, callbacks, options)
|
- Fields borrowed from class BTM.AJAX.Request:
- response
| Method Attributes | Method Name and Description |
|---|---|
|
update(response)
Exposed method to allow Element to be updated based on response
|
- Methods borrowed from class BTM.AJAX.Request:
- readyStateChanged, run
Class Detail
BTM.AJAX.Updater(selector, url, callbacks, options)
- Parameters:
- {HTMLElement|String} selector
- element ID or element reference to update with response from AJAX call
- {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, and the Element update 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
Method Detail
update(response)
Exposed method to allow Element to be updated based on response
- Parameters:
- response