Fri
31
Mar '06
Here is my simple ajax code…..
<div id=“divTxt”> </div>
<script language=“javascript”>
var req = new XMLHttpRequest();
req.open(“GET”, “test.html”,true);
req.onreadystatechange = function () {
document.getElementById(‘divTxt’).innerHTML = “Contents : “ + req.responseText;
}
req.send(null);
</script>
HTML Source - test.html
<html>
<head>
<meta http-equiv=“content-type” content=“text/html; charset=UTF-8″>
</meta></head>
<body>
apple<br />
orange<br />
pencil<br />
box<br />
bottle<br />
computer<br />
cat<br />
dog<br />
fox<br />
windows<br />
linux<br />
unix<br />
freebsd<br />
blah<br />
</body>
</html>
This code is compatible with Mozilla based browsers only. Eg: Firefox for windows 
Leave a passing comment »