Skip to content

Instantly share code, notes, and snippets.

@LB-Digital
Created July 7, 2018 00:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LB-Digital/25489daee3b18b614396a9c5267a6d72 to your computer and use it in GitHub Desktop.
Save LB-Digital/25489daee3b18b614396a9c5267a6d72 to your computer and use it in GitHub Desktop.
Reading JSON files in Javascript
var xmlhttp = new XMLHttpRequest();
var url = "myFile.json";
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myArr = JSON.parse(this.responseText);
myFunction(myArr);
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment