在PHP和JQuery之间传递DOMDocument


Passing DOMDocument between PHP and JQuery

问题是关于在PHP和JQuery之间通信对象。

在JQuery中执行$.post时,我想检索在"get_domdoc.php"中生成的DOMDocument对象,然后能够将其$.post返回到其他php文件,如:

    $.post("get_domdoc.php", {url: url}, function( domdoc )
    {
    //prepare 'domdoc' to $.post it - in a usable format - to another PHP file
    });

这可能吗?感谢您的帮助。

最简单的方法可能是在发送PHP脚本中将其转换为字符串,在jQuery中将其视为字符串数据,并在接收PHP脚本中创建新的DOMDocument

理论上,您可能能够serialize() DOMDocument对象,但这感觉很笨拙(如果可能的话)。交换正确的XML看起来像是IMO.