Created
September 17, 2012 01:32
-
-
Save dannygarcia/3735115 to your computer and use it in GitHub Desktop.
test js syntax highlight
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
// Simple ajax function to avoid using jQuery (°-°) | |
var ajax = function (url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', url, true); | |
xhr.send(); | |
xhr.onreadystatechange = function (e) { | |
if (e.target.status === 200 && e.target.readyState === 4) { | |
callback(e.target.response); | |
} | |
}; | |
}; | |
// Example | |
ajax("http://news.ycombinator.com/", function (data) { | |
console.log(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment