We know AJAX is the one of the clent side technology.Using Ajax is very simple and elegant for web programmers
Using Ajax we need the following essentials
Creating XMLHttpRequest objects.
Configuring XMLHttpRequest objects.
Handling data downloads from the server using anonymous functions.
Fetching text data from the server.
Passing data to the server using Ajax and the GET and PUT HTTP methods.
Fetching XML data from the server and decoding that data.
Fetching XML data from the server by passing data to the server.
Please see the below Examble.
<html>
<head>
<title>An Ajax example</title>
<script language = “javascript”>
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest){
XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
XMLHttpRequestObject = new
ActiveXObject(“Microsoft.XMLHTTP”);
}
function getData(dataSource, divID)
{
if(XMLHttpRequestObject) {
var obj = document.getElementById(divID);
XMLHttpRequestObject.open(“GET”, dataSource);
XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 &&
XMLHttpRequestObject.status == 200){
obj.innerHTML = XMLHttpRequestObject.responseText;
}
}
XMLHttpRequestObject.send(null) ;
}
}
</script>
</head>
<body>
<H1>An Ajax example</H1>
<form>
<input type = “button” value = “Fetch the message”
onclick = “getData(‘data.txt’, ‘DisplayHere’)”>
</form>
<div id = “DisplayHere”>
The fetched message will appear here.
</div>
</body>
</html>
Happy Coding.