FST Experiment 1
FST Experiment 1
<!DOCTYPE html>
<html>
<head>
<br><br><br>
<center><img src="autonoms logo.jpg" width="200" height="200" alt="Welcome"></center>
<h1 style="font-size:45px;color: rgb(255, 0, 72);margin-top:5px;"><center><marquee>
<b>WELCOME TO ST.ANN's COLLEGE OF ENGINEERING &TECHNOLOGY</b>
</center></marquee></h1>
<font face="verdana" size="6" color="blue">
<h2 ><center><b>DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
</center></font></h2>
<script language ="javascript">
function loadDoc()
{
var xhttp = new XMLHttpRequest(); // create the XMLHttpRequest object.
//Opens the request specifying get or post method and url, but specifies asynchronous or not.
xhttp.open("GET","ajax1.txt", true);
xhttp.send(); //Sends GET request.
//onreadystatechange property defines a function to be executed when the readyState changes.
//A callback function is a function passed as a parameter to another function.
xhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200) //Holds the status of the XMLHttpRequest.
//When readyState is 4 and status is 200, the response is
ready
{
// getElementById() finds element with id 'demo' and returns an object of type element.
//The innerHTML property sets or returns the HTML content of an element div.
document.getElementById("demo").innerHTML = this.responseText;
}
};
}
</script>
</head>
<body>
<div id="demo">
<h2 style="font-size:40px;color: rgb(255, 0, 170);margin-top:5px;"><center>WELCOME TO
AJAX </center></h2>
<center><button type="button" onclick="loadDoc()"> <font face="verdana"
size="3"color="green"><h2>CHANGE CONTENT</button></h2></center></font>
</div>
</body>
</html>
Ajax1.txt
AJAX is a Group of inter-related Technologies like HTML, CSS, JavaScript, XML, DOM etc.
OUTPUT:
If we click on ‘CHANGE CONTENT’ button then ‘ajax1.txt’ file content will be displayed as
shown below.