Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Aviance School is one of the largest web solutions platform in India for developers to learn and share their programming knowledge and build their careers.
XMLHttpRequest is an API in the form of an object data whose methods transfer data between a client or web browser and a server.
It provides an easy way to get data from a URL without refreshing the web page. Send data to a web server in the background.XMLHttpRequest is mostly used in AJAX programming.
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLData(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("data").innerHTML = xmlhttp.responseText;
}
};
xhttp.open("GET", "sample.php", true);
xhttp.send();
}
</script>
</head>
<body>
<div id="data">
<button type="button" onclick="loadXMLData()">Click here to get data</button>
</div>
</body>
</html>