Skip to content

Instantly share code, notes, and snippets.

@seunggabi
Last active May 5, 2019 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seunggabi/dc173f72b8b5c8f0909c8b6bea7e747b to your computer and use it in GitHub Desktop.
Save seunggabi/dc173f72b8b5c8f0909c8b6bea7e747b to your computer and use it in GitHub Desktop.
post.js
function post(url, body) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
console.log(this);
console.log(url, body);
}
};
xhr.send(body);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment