我使用 javascript 更改了 XMLDocument 本地位置。如何将其保存到服务器上?我尝试了以下方法:
if (window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else{ // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","./path/to/phpfile/file.php?newdocument="+newxmldocument,true);
xmlhttp.send();
在 php 文件中我想做这样的事情:
$file = "./path/to/xmlfile/xmlfile.xml";
$dom = new DOMDocument();
$dom = $_REQUEST['newdocument'];
$dom->save($file);
但是,这不起作用。
是否有一种简单的方法来保存 php 文件接收的 XMLDocument 对象?
最佳答案
您应该尝试使用 POST 作为多部分发送 XMLDocument。
关于javascript - 使用 php 将在 javascript 中创建的 XMLDocument 对象保存在服务器上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24160555/