Using JavaScript to post XML to PHP

    Date: 08/22/05 (PHP Community)    Keywords: php, xml, java, microsoft

    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 = "bar";
    
    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?

    Source: http://www.livejournal.com/community/php/338326.html

« CMS/Application platforms || Source File Location »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home