Created
September 8, 2017 03:02
-
-
Save tripplyons/70d6be83d422cd219297a3d18012133a to your computer and use it in GitHub Desktop.
HTTP GET JavaScript
This file contains 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
function get(url, cb) { | |
var xhr = new XMLHttpRequest() | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState == 4 && xhr.status == 200) { | |
cb(xhr.responseText) | |
} | |
} | |
xhr.open("GET", url, true) // true for asynchronous | |
xhr.send(null) | |
} |
This file contains 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
function get(e,t){var n=new XMLHttpRequest;n.onreadystatechange=function(){4==n.readyState&&200==n.status&&t(n.responseText)},n.open("GET",e,!0),n.send(null)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment