Created
June 5, 2019 22:56
-
-
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.
This file contains hidden or 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 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