Created
August 23, 2013 18:42
-
-
Save morningtoast/6322641 to your computer and use it in GitHub Desktop.
Vanilla ajax
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 ajax(url, callback) { | |
| var xmlhttp; | |
| xmlhttp = new XMLHttpRequest(); | |
| xmlhttp.onreadystatechange = function() { | |
| if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { callback(xmlhttp.responseText); } | |
| } | |
| xmlhttp.open("GET", url, true); | |
| xmlhttp.send(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment