Created
March 14, 2014 08:35
-
-
Save keyle/9544102 to your computer and use it in GitHub Desktop.
Simple ajax, pure javascript, no jquery
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 callAjax(url, callback){ | |
| var xmlhttp; | |
| // compatible with IE7+, Firefox, Chrome, Opera, Safari | |
| 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