CAPH.DAL.XHRLOADER
XHRLoader is a class that loads a resource using XMLHttpRequest, also known as XHR. Main API of XHRLoader is 'load.' Using load method, a user can load resource with a given URL using XMLHttpRequest. Also, XHRLoader is used by Preloader which can preload resources using XMLHttpRequest.
Contents
Constructor
XHRLoader | ||
Description | ||
construct an XHRLoader | ||
Emulator Support | Y | |
SDK Constraint | None | |
Example | ||
var XHRloader = caph.dal.XHRLoader; var xhrloader = new XHRloader(); console.log(xhrloader); // Must not be undefined |
Methods
XHRLoader | ||
Description | ||
(Constructor) construct an XHRLoader | ||
Parameters | ■Void | |
Return | ■XHRLoader - An instance of XHRLoader | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var XHRloader = caph.dal.XHRLoader; var xhrloader = new XHRloader(); console.log(xhrloader); // Must not be undefined |
hasValidArgsForLoading | ||
Description | ||
check if it has valid arguments for loading | ||
Parameters | ■Void | |
Return | ■Boolean - A flag to indicate a valid state or not | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var XHRloader = caph.dal.XHRLoader; var xhrloader = new XHRloader(); var flag = xhrloader.hasValidArgsForLoading(); |
getBlob | ||
Description | ||
Returns a Blob. | ||
Parameters | ■Void | |
Return | ■Blob - A blob | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); var result = xhrloader.getBlob(); |
getResponse | ||
Description | ||
Get the XHR's response. If it has any | ||
Parameters | ■Void | |
Return | ■Any - An XHR's response | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); var result = xhrloader.getResponse(); |
getResponseText | ||
Description | ||
Get the XHR's reponseText. If it has any | ||
Parameters | ■Void | |
Return | ■String - An XHR's responseText | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); var result = xhrloader.getResponseText(); |
getNode | ||
Description | ||
get the node | ||
Parameters | ■Void | |
Return | ■Document Element - Node | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); var tag = xhrloader.getNode(); |
isSuccessfulXHR | ||
Description | ||
check if XHR was succeeded | ||
Parameters | ■Void | |
Return | ■Boolean - A flag to indicate a valid state or not | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var XHRloader = caph.dal.XHRLoader; var xhrloader = new XHRloader(); var xhr = new XMLHttpRequest(); var flag = xhrloader.isSuccessfulXHR(xhr); //return true or false |
cleanup | ||
Description | ||
Clean up itself | ||
Parameters | ■Void | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); xhrloader.cleanup(); |
cleanupOnComplete | ||
Description | ||
clean up itself after completion | ||
Parameters | ■Void | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); xhrloader.cleanupOnComplete(); |
init | ||
Description | ||
initialize XHRLoader | ||
Parameters | ■Void | |
Return | ■Boolean - false : if fails; undefined, otherwise; | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var XHRloader = caph.dal.XHRLoader; var xhrloader = new XHRloader(); xhrloader.init(); |
loadURL | ||
Description | ||
load a URL | ||
Parameters | ■Void | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var XHRloader = caph.dal.XHRLoader; var xhrloader = new XHRloader(); xhrloader.init(); // Let's say options and url are given. xhrloader.load(options, '4', DC.TYPE_JPEG, url); // URL is already given, so load the URL xhrloader.loadURL(); xhrloader.stop(); |
load | ||
Description | ||
Load a resource | ||
Parameters | ■options - Object - { {String} sourceTypeString // source type string {String} IDForTag // id attr. to use {function} onComplete // on completion callback {function} onError // on error callback {function} onLoadStart // on loadstart callback {Array} onCompleteArg } | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var XHRloader = caph.dal.XHRLoader; var xhrloader = new XHRloader(); xhrloader.load( { flagBlob:true }, '3', DC.TYPE_JPEG, url ); |
onRequestFinishedAndResponseIsReady | ||
Description | ||
called when request finished and response is ready | ||
Parameters | ■Void | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var XHRloader = caph.dal.XHRLoader; var xhrloader = new XHRloader(); xhrloader.onRequestFinishedAndResponseIsReady(); |
onXHRError | ||
Description | ||
called when an XHR error is occurred | ||
Parameters | ■Void | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var XHRloader = caph.dal.XHRLoader; var xhrloader = new XHRloader(); xhrloader.onXHRError(); |
onXHRLoad | ||
Description | ||
called when an XHR load is completed | ||
Parameters | ■Void | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var XHRloader = caph.dal.XHRLoader; var xhrloader = new XHRloader(); xhrloader.onXHRLoad(); |
processResponse | ||
Description | ||
process an XHR response | ||
Parameters | ■Void | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); xhrloader.processResponse(); |
stop | ||
Description | ||
stop the loader | ||
Parameters | ■Void | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); var DC = caph.dal.Constant; function foo() { console.log('function foo is called'); } xhrloader.init(); xhrloader.subscribe('oncomplete', foo, 'foofoo'); // Let's say options and url are given. xhrloader.load(options, '4', DC.TYPE_JPEG, url); // URL is already given, so load the URL xhrloader.loadURL(); xhrloader.stop(); |
subscribe | ||
Description | ||
subscribe to an event | ||
Parameters | ■typeString - String - type string of an event - [default : null] ■callback: - Function - A callback function to be called - [default : null] | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); var DC = caph.dal.Constant; function foo() { console.log('function foo is called'); } xhrloader.init(); xhrloader.subscribe('oncomplete', foo, 'foofoo'); // Let's say options and url are given. xhrloader.load(options, '4', DC.TYPE_JPEG, url); // URL is already given, so load the URL xhrloader.loadURL(); xhrloader.stop(); |
publish | ||
Description | ||
publish an event | ||
Parameters | ■typeString - String - type string of an event - [default : null] ■callbackThis: - Any - A callback parameter to be transferred as this - [default : null] ■callbackData: - Any - A callback parameter to be transferred as data - [default : null] | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); var DC = caph.dal.Constant; function foo() { console.log('function foo is called'); } xhrloader.init(); xhrloader.subscribe('oncomplete', foo, 'foofoo'); // Let's say options and url are given. xhrloader.load(options, '4', DC.TYPE_JPEG, url); // URL is already given, so load the URL xhrloader.loadURL(); xhrloader.stop(); xhrloader.publish('oncomplete', xhrloader, null); |
unsubscribe | ||
Description | ||
unsubscribe to an event | ||
Parameters | ■typeString - String - type string of an event - [default : null] ■callback: - Function - A callback function to be called - [default : null] | |
Return | ■Void | |
Emulator Support | Y | |
SDK Constraint | none | |
Example | ||
var Xhrloader = caph.dal.XHRLoader; var xhrloader = new Xhrloader(); var DC = caph.dal.Constant; function foo() { console.log('function foo is called'); } xhrloader.init(); xhrloader.subscribe('oncomplete', foo, 'foofoo'); // Let's say options and url are given. xhrloader.load(options, '4', DC.TYPE_JPEG, url); // URL is already given, so load the URL xhrloader.loadURL(); xhrloader.stop(); xhrloader.unsubscribe('oncomplete', foo); |