Flirting with AJAX
I started to find out about AJAX, a fashion Web technology, which stands for Asynchronous JavaScript And XML; Hatem’s blog helped me a lot, and the Internet is a huge source of information.
A “hello world” application is like the following: it requests data from page.php and writes the content between div tag identified by “willchange”. Not as complicated as it seems to be…
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" Another script to show memory status (works only on UNIX)
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
<script type="text/javascript">
var http = new XMLHttpRequest();
function sndReq() {
http.open("get","page.php");
http.setRequestHeader("user-agent","A robot made by Swobodin, just to test
");
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if (http.readyState == 4) {
var response = http.responseText;
document.getElementById("willchange").innerHTML = response;
}
}
</script>
<title></title>
</head>
<body onload="sndReq()">
<div id="willchange">
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
var http = new XMLHttpRequest();
window.setInterval("RqSend()",1000);
function RqSend() {
http.open("get", "/proc/meminfo",true);
http.onreadystatechange = update_all;
http.send(null);
}
function update_all() {
if (http.readyState == 4) {
var response = http.responseText;
document.getElementById("main").innerHTML = "<pre>\n"+response+"\n<\/pre>";
}
}
</script>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
<title>Memory Status</title>
</head>
<body onload='RqSend()'>
<div id="main">
</div>
</body>
</html>
It’s crazy what you can do with AJAX! Flickr and Gmail are typical examples of the perfect mastering of it.
I liked the gallery application, lightbox, you may check it out here…

April 27th, 2006 at 2:31 pm
cooooooooooooooooooooooooooooooooooooooooooooooooooooooooooolll
I like this tech a lot toooooo