amoussa11

Sending an XMLHttpRequest

Feb 19th, 2019
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 0.52 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h2>Using the XMLHttpRequest Object</h2>
  6.  
  7. <div id="demo">
  8. <button type="button" onclick="loadXMLDoc()">Change Content</button>
  9. </div>
  10.  
  11. <script>
  12. function loadXMLDoc() {
  13.   var xhttp = new XMLHttpRequest();
  14.   xhttp.onreadystatechange = function() {
  15.     if (this.readyState == 4 && this.status == 200) {
  16.      document.getElementById("demo").innerHTML =
  17.      this.responseText;
  18.     }
  19.   };
  20.   xhttp.open("GET", "xmlhttp_info.txt", true);
  21.   xhttp.send();
  22. }
  23. </script>
  24.  
  25. </body>
  26. </html>
Advertisement
Add Comment
Please, Sign In to add comment