Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Vanilla Javascript AJAX Function
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
You can’t perform that action at this time.