Created
July 29, 2014 08:46
-
-
Save lukehedger/cd520d2b3bf516778140 to your computer and use it in GitHub Desktop.
XMLHttpRequest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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