2011-01-06 104 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');