2011-01-06 65 views
0

我现在正在使用Javascript,并希望发送(firstrequest.responseXML)到一个PHP脚本,并找不到任何资源如何做到这一点。我想:通过发送请求发送到PHP脚本的XML文档对象

var http = new XMLHttpRequest(); 
var url = "http://.../pref.php"; 
var params = prefxml; //prefxml is the responseXML 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); 

在PHP脚本我试图通过$ _ POST抓住它[“PARAMS”],但我没有得到它的工作。 请求功能是否正确?如果是的话我怎样才能在PHP文件中使用xml文档对象?

感谢您的任何帮助。我真的无法得到这个问题的答案。

回答

0

你有没有在你的PHP脚本试图

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