//AJAX Program demonstrating how to create an XMLHttpRequest object
Ajax1.html
<html>
<head>
<title>Ajax Example 1</title>
<script type="text/javascript">
var xmlhttp=false;
if(window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHttp");
}
//Now you can start writing HTML as usual, after checking for the presence of the XMLHttpRequest object
if(xmlhttp)
{
document.write("<h1>Hello World from AJAX</h1>");
}
</script>
</head>
<body>
</body>
</html>
You can double click the the above program to run it just like any other HTML file.
Snapshot of the o/p
