Last active
September 26, 2015 23:57
-
-
Save segdeha/1178876 to your computer and use it in GitHub Desktop.
Simplest possible Ajax implementation
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 ajax(url, callback) { | |
var xhr; | |
xhr = new XMLHttpRequest(); | |
xhr.open('GET', url, true); | |
xhr.onreadystatechange = function () { | |
if (4 === xhr.readyState && 400 > xhr.status) { | |
callback(xhr); | |
} | |
}; | |
xhr.send(null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment