Saturday, February 25, 2017

AJAX example

<!DOCTYPE html>
<html>
<head>

<meta name = "keywords" content = "ajax,example"/>

<script>
function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     document.getElementById("demo").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "AJAX.htm", true);
  xhttp.send();
}</script>
</head>

<body>

<div id="demo">
  <h2>Let AJAX change this text</h2>
  <button type="button" onclick="loadDoc()">Change Content</button>
</div>

</body>
</html>

No comments:

Post a Comment