Skip to content

Instantly share code, notes, and snippets.

@luisenriquecorona
Created June 5, 2019 22:56
Show Gist options
  • Save luisenriquecorona/554d7c1afd1986284b0c4c48b8ea86ab to your computer and use it in GitHub Desktop.
Save luisenriquecorona/554d7c1afd1986284b0c4c48b8ea86ab to your computer and use it in GitHub Desktop.
uses each of the XMLHttpRequest. It POSTs a string of text to a server and ignores any response the server sends.
function postMessage(msg) {
var request = new XMLHttpRequest(); // New request
request.open("POST", "/log.php"); // POST to a server-side script
// Send the message, in plain-text, as the request body
request.setRequestHeader("Content-Type", // Request body will be plain text
"text/plain;charset=UTF-8");
request.send(msg); // Send msg as the request body
// The request is done. We ignore any response or any error.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment