1var xhttp = new XMLHttpRequest();
2xhttp.onreadystatechange = function() {
3 if (this.readyState == 4 && this.status == 200) {
4 // Typical action to be performed when the document is ready:
5 document.getElementById("demo").innerHTML = xhttp.responseText;
6 }
7};
8xhttp.open("GET", "filename", true);
9xhttp.send();
1function reqListener () {
2 console.log(this.responseText);
3}
4
5var oReq = new XMLHttpRequest();
6oReq.addEventListener("load", reqListener);
7oReq.open("GET", "http://www.example.org/example.txt");
8oReq.send();