Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
481 B
2
Indexable
Never
<html>
<body>
<div id="div1">
<h1> XMLHttpRequest Object</h1>
<button type="button" onclick="loadDoc()">Changer le contenu</button>
</div>
<script>
function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("div1").innerHTML =
      this.getAllResponseHeaders();
    }
  };
  xhttp.open("GET", "file1.txt", true);
  xhttp.send();
}
</script>
</body>
</html>