【问题标题】:Sending xml document object via post request to a php script通过 post 请求将 xml 文档对象发送到 php 脚本
【发布时间】: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 文档对象?

感谢您的帮助。这个问题我真的找不到答案。

【问题讨论】:

    标签: php xml ajax


    【解决方案1】:

    你试过了吗

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

    在你的 php 脚本中?

    【讨论】:

      猜你喜欢
      • 2010-12-02
      • 2017-05-19
      • 1970-01-01
      • 1970-01-01
      • 2016-09-22
      • 1970-01-01
      • 2012-03-15
      • 2021-08-02
      • 2011-10-24
      相关资源
      最近更新 更多