Using JavaScript to post XML to PHP
I've been trying to use JavaScript's XMLHttpRequest object to send XML to a PHP form. As far as sending the XML goes, I've got that worked out:
try
{
var req = new XMLHttpRequest();
}
catch(e)
{
var req = new ActiveXObject("Microsoft.XMLHTTP");
}
someXML = "<root><foo>bar</foo></root>";
req.open("POST", "example.php", false);
req.setRequestHeader("Content-Type", "text/xml");
req.send(someXML);
response = req.responseXML;What I'm stuck on is how to get the PHP to receive anything in req.send(). The $_POST array only seems to store whatever I put into a query string in my URL, e.g.:req.open("POST", "example.php?foo=bar", false);
req.send('');If I have to I guess I can just send my input that way, but I figure there must be some way PHP can recieve XML from a POST request. Any thoughts? 