Mootools 1.2 – Update any element with Ajax
Sunday, May 18th, 2008
Easily update any element's inner html with an ajax get request.
Simple get request
$('div_files').load('getfiles.php');What it does is get the content of getfiles.php and uses it as the innerHtml for the div with id
'div_files'
Slightly more complex get request
var myHTMLRequest = new Request.HTML({url:'getfiles.php', update:'div_files'}).get({'user_id': 25});In this get request, like the simple one you specify the location of the server side script, which happens to be in the same directory, and you specify the element who's innerHtml you want to update. After the
.get
you send a variable to the server, in this case
user_idwith the value 25. Note: In the php file you'll need to use a
$_GET['user_id']instead of
$_POST 

