开发者

Sending xml document object via post request to a php script

I'm using Javascript right now and want to send(firstrequest.responseXML) to a php script and couldn't find any resource how to do that. I tried:

var http = new XMLHttpRequest();
var url = "http://.../pref.php";
var params = prefxml; //prefxml is the respo开发者_开发问答nseXML object of the last request
http.open("POST", url, true);


http.setRequestHeader("Content-type", "txt/xml");

//I'm not sure which header to use for sending a xml document object.
http.onreadystatechange = function() {//Call a function when the state changes.
    if(http.readyState == 4 && http.status == 200) {
        alert(http.responseText);
    }
}

http.send(params);

In the php script I tried to catch it via $_POST['params'] but I didn't get it working. Is the request function right? And if yes how can I use the xml document object in the PHP file?

Thanks for any help. I really couldn't get an answer for this question.


Have you tried

$your_xml = file_get_contents('php://input');

in your php script ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜