Skip to content

Instantly share code, notes, and snippets.

@jgermade
Created October 25, 2016 15:33
Show Gist options
  • Save jgermade/36a19a3fb80f9a26afea8b9e410eb8f6 to your computer and use it in GitHub Desktop.
Save jgermade/36a19a3fb80f9a26afea8b9e410eb8f6 to your computer and use it in GitHub Desktop.
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if(request.readyState === 4) {
if(request.status === 200) {
console.log(request.responseText);
} else {
console.error(request.status, request.statusText, request.responseText);
}
}
}
request.open('POST', 'http://hostname:post/api/endpoint', true);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send('foo=bar');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment