LAjax Class
AJAX is the art of exchanging data with a server, and update parts of a web page - without reloading the whole page.
Constructor
LAjax
()
public
Methods
get
(
public
-
url
-
data
-
oncomplete
-
onerror
The method loads data from the server using a HTTP GET request.
Parameters:
-
url
StringRequired. Specifies the URL you wish to request
-
data
Json ObjectOptional. Specifies data to send to the server along with the request
-
oncomplete
FunctionOptional. Specifies a function to run if the request succeeds
-
onerror
FunctionOptional. Specifies a function to run if the request failure
Example:
LInit(1000/50,"legend",800,450,main);
var label;
function main(){
label = new LTextField();
addChild(label);
label.x = label.y = 50;
label.text = "LAjax.get ......";
LAjax.get("test.txt",{},success);
}
function success (data) {
label.text = data;
}
post
(
public
-
url
-
data
-
oncomplete
-
onerror
The method loads data from the server using a HTTP POST request.
Parameters:
-
url
StringRequired. Specifies the URL you wish to request
-
data
Json ObjectOptional. Specifies data to send to the server along with the request
-
oncomplete
FunctionOptional. Specifies a function to run if the request succeeds
-
onerror
FunctionOptional. Specifies a function to run if the request failure
Example:
LInit(1000/50,"legend",800,450,main);
var label;
function main(){
label = new LTextField();
addChild(label);
label.x = label.y = 50;
label.text = "LAjax.post ......";
LAjax.post("test.txt",{},success);
}
function success (data) {
label.text = data;
}