Blogs
Liferay.com
Let's prep our sandbox, but this time, the module we're going to use is called "aui-io-request".
HTML5 Gallery for our recent move to HTML5. Visit their entry for Liferay @ http://html5gallery.com/2010/03/liferay/. AUI().use('aui-io-request', function(A){

What is HTML5 Gallery? HTML5 Gallery showcases sites using HTML5 markup, and right now we're one of only five commercial sites listed, and within that category one of only two in English. We're also the only featured portal company running HTML5. Take the time to check out the site, other sites running HTML5, and rate some of your favorite HTML5 websites.
What is HTML5 and what is all the fuss about? HTML5 is a new version of HTML which addresses new challenges we face in modern web development; everything from writing web applications and maintaining sanity, creating // Our code will run here });
The simple of the simple, let's assume we're just going to be making a simple ajax request to a plain html file, called "test.html".
A.io.request('test.html');
That's all there is to it. However, that's not very interesting because it doesn't do anything.
Let's say want to send a POST request to the server:
A.io.request('test.html', {
method: 'POST',
data: {
key1: 'value'
}
});
How about responding to the server? There are 5 possible callbacks: start, complete, success (or) failure, and end.
If I wanted to alert the response from the server, here's what I would do:
A.io.request('test.html', {
on: {
success: function() {
alert(this.get('responseData'));
}
}
});
What is this.get('responseData')? It's basically a normalized property of what is returned from the server. It's useful because A.io.request supports having different types of data returned by the server and automatically handled.
For instance, if your server returns JSON like {"myProperty": 2}, you could do something like:
A.io.request('test.html', {
dataType: 'json',
on: {
success: function() {
alert(this.get('responseData').myProperty); //alerts 2
}
}
});
You can also work with XML that way. Assuming your server returns something like: <name>AlloyUI</name> you could do:
A.io.request('test.html', {
dataType: 'xml',
on: {
success: function() {
alert(A.all(this.get('responseData')).all('name').text()); // alerts AlloyUI
}
}
});
You can also submit all of the data in a form via ajax as well. Here's the simplest version:
A.io.request('test.html', {
form: {