CAPH.CORE
The "core" is a namespace which provides various kinds of basic features related to Web Application, such as Selector and AJAX.
Contents
Methods
getElement | ||
Description | ||
Return DOM Elements. | ||
Parameters | ■selector - String - the selector that you want to find. When the prefix is "#", finds element by id. When the prefix is ".", finds element by class name. When the prefix is not exist, finds element by name. ■root (Optional) - DocumentElement - Start to find element from 'root' element which is passed by parameter. If it is not provided, find element from 'document' element. | |
Return | ■DocumentElement Array - The list of DocumentElements. | |
Emulator Support | Y | |
SDK Constraint | Support from version 5.1 | |
Example | ||
var testElement = caph.core.getElement("#test"); var myClassElements = caph.core.getElement(".myClass"); var divElements = caph.core.getElement("div", caph.core.getElement("#test")); |
ajax | ||
Description | ||
Perform an asynchronous HTTP (Ajax) request. | ||
Parameters | ■url - String - The URL to which the request is sent. ■option - Object - A set of key/value pairs that configure the Ajax request. * method : (String) The type of request to make ("POST" or "GET") - [default : "GET"] * async : (Boolean) By default, all requests are sent asynchronously. If you need synchronous requests, set this option to false. - [default : true] * parameter : (String) Data to be sent to the server. It is converted to a query string, if not already a string. K1347Object must be Key/Value pairs. * type : (String) The type of data that you're expecting back from the server. - value : XML, HTML, TEXT, JSON, JSONP - [default : "XML"] * header : (Array) additional header key/value pair objects to send along with requests using the XMLHttpRequest transport. * cbHandler : (Function) to be called when the request finishes. The function gets passed one or more arguments. The Response object and cbParameter array. * cbParameter : (Array) which is passed to cbHandler function. * jsonpCharset : Only applies when the "JSONP" type is used. Sets the charset attribute on the script tag used in the request. * jsonpCallback : Override the callback function name in a jsonp request. This value will be used instead of '_callback' in the '_callback=' part of the query string in the url. | |
Return | ■Object - Response object, including xhr, type, value. | |
Emulator Support | Y | |
SDK Constraint | Support from version 5.1 | |
Example | ||
caph.core.ajax("/test", { method: "get", type: "TEXT", parameter: "param1=1¶m2=2", cbHandler: function(response) { alert(response.value); } }); |