Skip to content

Instantly share code, notes, and snippets.

@AlexiyOrlov
Created November 19, 2019 15:10
Show Gist options
  • Save AlexiyOrlov/3111fdb52d82c2962dd8fc5ba576fadb to your computer and use it in GitHub Desktop.
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.
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