Created
February 1, 2014 21:07
-
-
Save koistya/8758886 to your computer and use it in GitHub Desktop.
Send Ajax request with vanilla JavaScript
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
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', '/api/sum?a=1&b=2', false); | |
xhr.send(null); | |
console.log(xhr.responseText); // prints 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should use this for better cross-browser support (IE 5, IE 6).