Last active
August 17, 2020 01:34
-
-
Save youngchief-btw/c1b82851f1a78f68681d1668cf7eba75 to your computer and use it in GitHub Desktop.
A function that does XMLHttpRequest handling and such
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function XMLHttpRequestFUNC(method, url, async) { | |
var xhr = new XMLHttpRequest(); | |
xhr.onreadystatechange = function() { | |
if (xhr.readyState == 4 && xhr.status == 200) { | |
console.log(xhr.response); | |
return; | |
} | |
}; | |
xhr.open(method, url, async); // arguments[#] | |
// xhr.setRequestHeader("User-Agent", "https://youngchief-btw.github.io/"); // header, value | |
xhr.getAllResponseHeaders(); | |
xhr.send(); | |
} | |
// Usage Example: | |
// XMLHttpRequestFUNC("GET", "https://www.uuidgenerator.net/api/version4/500", true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment