Last active
July 19, 2020 01:54
-
-
Save DmitriyShaydurov/97abb4200785373587edb67538cbb1cb to your computer and use it in GitHub Desktop.
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
// GET: | |
const Http = new XMLHttpRequest(); | |
const url='http://example.com/'; | |
Http.open("GET", url); | |
Http.send(); | |
Http.onreadystatechange=(e)=>{ | |
if (Http.readyState === 4) { | |
console.log(Http.responseText); | |
} | |
} | |
//POST: | |
var xhr = new XMLHttpRequest(); | |
xhr.open("POST", '/user', true); | |
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); | |
xhr.onreadystatechange = function() { | |
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) { | |
var return_data = hr.responseText; | |
// Request finished. Do processing here. | |
} | |
} | |
xhr.send("name=Ipseeta&id=1"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment