【发布时间】:2011-01-06 13:19:47
【问题描述】:
我现在正在使用 Javascript,想将(firstrequest.responseXML) 发送到一个 php 脚本,但找不到任何资源如何做到这一点。我试过了:
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 文档对象?
感谢您的帮助。这个问题我真的找不到答案。
【问题讨论】: