Skip to content

Instantly share code, notes, and snippets.

@lukehedger
Created July 29, 2014 08:46
Show Gist options
  • Save lukehedger/cd520d2b3bf516778140 to your computer and use it in GitHub Desktop.
Save lukehedger/cd520d2b3bf516778140 to your computer and use it in GitHub Desktop.
XMLHttpRequest
request = new XMLHttpRequest();
request.open('GET', '/data/data.json', true);
request.onload = function() {
if (this.status >= 200 && this.status < 400){
data = JSON.parse(this.response);
console.log(data);
} else {
console.log("Data error");
}
};
request.onerror = function() {
console.log("Connection error");
};
request.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment