Created
November 7, 2019 05:12
-
-
Save johnhutchins/03d0f33d0208196a00282e8041595651 to your computer and use it in GitHub Desktop.
base requestAjax function
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
function requestAJAX(url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function () { | |
if (xhr.readyState == 4 && xhr.status == 200) { | |
callback(JSON.parse(xhr.responseText)) | |
} | |
} | |
xhr.open('GET', url, true) | |
xhr.send() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment