Skip to content

Instantly share code, notes, and snippets.

@madhavan-rp
Last active August 29, 2015 13:56
Show Gist options
  • Save madhavan-rp/8858467 to your computer and use it in GitHub Desktop.
Save madhavan-rp/8858467 to your computer and use it in GitHub Desktop.
Javascript Snippets
function f1() {
xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST","/api/v1/endpoint",true);
xmlhttp.setRequestHeader("Content-Type","application/json");
xmlhttp.send(JSON.stringify({"text":"Classify this!"}));
console.log("" + xmlhttp.responseText);
}
function get() {
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
console.log("Got Response");
}
}
var link = "<URL here>";
xmlhttp.open("GET",link,true);
xmlhttp.send(null);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment