Skip to content

Instantly share code, notes, and snippets.

@johnhutchins
Created November 7, 2019 05:12
Show Gist options
  • Save johnhutchins/03d0f33d0208196a00282e8041595651 to your computer and use it in GitHub Desktop.
Save johnhutchins/03d0f33d0208196a00282e8041595651 to your computer and use it in GitHub Desktop.
base requestAjax function
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