I want to save logs of user’s operation by accessing log script file(for example, log.php) with post or get parameter from my flash application.
The flash is web application not desktop application.
In jQuery, javascript can access other files on the web site by using the following code:
$.post("test.php", {a: 1, b: 2}, function(data) {
console.log(data);
});
$.post’s document:
http://api.jquery.com/jQuery.post/
I think the following actionscript code is equivalent to the jQuery’s $.post().
Does this code cause any problems which jQuery’s $.post() doesn’t?
Is there more simple and shorter way to do this?
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, function():void {
trace(loader.data);
});
var variables:URLVariables = new URLVariables();
variables.a = 1;
variables.b = 2;
var request:URLRequest = new URLRequest("test.php");
request.data = variables;
request.method = URLRequestMethod.POST;
try {
loader.load(request);
} catch (error:Error) {
trace("failed");
}
I think there is 3 more way to do the same…
First two are identical, just a protocol difference is there and according to me last one is best option.this is 8-10 time faster than other two.
You can find all details On Adobe Site