Created
April 10, 2016 15:33
-
-
Save marcusshepp/7bda7bcd9d379b77bef87a3d16484562 to your computer and use it in GitHub Desktop.
Vanilla Javascript AJAX Function
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 http_request = new XMLHttpRequest(); | |
http_request.open("GET", "{% url 'api_categories' %}"); | |
http_request.send(null); | |
http_request.onreadystatechange = function(){ | |
var DONE = 4; | |
var OK = 200; | |
if (http_request.readyState === DONE){ | |
if (http_request.status === OK){ | |
console.log(http_request.responseText); | |
} else { | |
console.log("Error: " + http_request.status); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment