Created
November 19, 2019 15:10
-
-
Save AlexiyOrlov/3111fdb52d82c2962dd8fc5ba576fadb to your computer and use it in GitHub Desktop.
XmlHttpRequest which POSTs a parameter to local server on document load and recieves a response as text.
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
let request = new XMLHttpRequest(); | |
request.responseType = 'text'; | |
document.onload = function () { | |
if (request.status === 200 && request.readyState === XMLHttpRequest.DONE) { | |
console.log(request.responseText) | |
} | |
else console.log(request); | |
}; | |
request.open('POST', 'http://localhost:4700', true); | |
request.send('param'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment