Example
// assume the url http://foo.bar returns a json parsed string: "{foo: 'bar'}"
siteKiosk.network.ajax.get('http://foo.bar', 'json', function(content) {
//content is now a regular javascript object since the request did not fail,
//this will log 'bar'
console.log(content.foo);
}, function(errorMessage) {
//error handling goes here
});
Methods
-
<static> get(url, type, loadedCallback, failedCallback)
-
Performs an HTTP request and parses the content.
Parameters:
Name Type Description url
string The request URL type
string The expected response type ("text", "xml", "json" or "html") loadedCallback
siteKiosk.network.ajax~loadedCallback A callback, which will be called when the content is loaded failedCallback
siteKiosk.network.ajax~failedCallback A callback, which will be called when the request failed -
<static> load(url, loadedCallback, failedCallback)
-
Performs an HTTP request without parsing.
Parameters:
Name Type Description url
string The request URL loadedCallback
siteKiosk.network.ajax~loadedCallback A callback, which will be called when the content is loaded failedCallback
siteKiosk.network.ajax~failedCallback A callback, which will be called when the request failed
Type Definitions
-
failedCallback(errorMessage)
-
An callback, being invoked, when an HTTP request failed.
Parameters:
Name Type Description errorMessage
string The error message -
loadedCallback(content)
-
An callback, being invoked, when an HTTP response has been loaded.
Parameters:
Name Type Description content
string | XMLDocument | Object | Array.<Node> The response content, whose type depends on the expected response type ("text", "xml", "json" or "html")