Skip to content

Instantly share code, notes, and snippets.

@brianzelip
Created August 6, 2017 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianzelip/0ee582814c64f16a1b1a3c67d444fc8e to your computer and use it in GitHub Desktop.
Save brianzelip/0ee582814c64f16a1b1a3c67d444fc8e to your computer and use it in GitHub Desktop.
function reqListener () {
  console.log(this.responseText);
}

var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "http://www.example.org/example.txt");
oReq.send();
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
        document.getElementById("demo").innerHTML = this.responseText;
        var obj=this.responseText;
        var obj1 = JSON.parse(obj);
        a0 = obj1.a0;
    }
};
xhttp.open("GET", "../data/data.json", true);
xhttp.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment