Example 12-30: Function to post XML document to a web server

// PostXMLDocument.js
// Uses HTTP POST to send XML Document "xmldoc" to URL "toURL"
function PostXMLDocument (xmldoc, toURL)
{
   // Create a new XMLHttpRequest Object (IE 5.0 or Higher)
   var xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP");
   // Open a synchronous HTTP Request for a POST to URL "toUrl"
   xmlhttp.open("POST", toURL ,  /* async = */ false );
   // Could set HTTP Headers Here (We don't need to in this example)
   // xmlhttp.setRequestHeader("some-header-param","some value");
   // Send the request with in-memory XML Document "xmldoc" as body
   xmlhttp.send(xmldoc);
   // Return the response from the request (assumes it is an XML Doc)
   return xmlhttp.responseXML;
}