Skip to content

Instantly share code, notes, and snippets.

@seunggabi
Last active January 2, 2020 11:53
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/6aa43dbcf4d5238d940f7b0b49fee989 to your computer and use it in GitHub Desktop.
Save seunggabi/6aa43dbcf4d5238d940f7b0b49fee989 to your computer and use it in GitHub Desktop.
requestUtils.js
function requestUtils(method, url, body) {
var xhr = new XMLHttpRequest();
xhr.open(method, url, true);
xhr.withCredentials = 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