postMessage.js

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. }
uses each of the XMLHttpRequest. It POSTs a string of text to a server and ignores any response the server sends.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.