The problem is about communicating an object between PHP and JQuery.
Performing $.post in JQuery, i want to retrieve a DOMDocument object generated in ‘get_domdoc.php’ and then be able to $.post it back to other PHP files, like:
$.post("get_domdoc.php", {url: url}, function( domdoc )
{
//prepare 'domdoc' to $.post it - in a usable format - to another PHP file
});
Is this possible? Appreciate any help.
The most straightforward way is probably turning it into a string in the sending PHP script, treating it as string data in jQuery, and creating a new
DOMDocumentin the receiving PHP script.You may theoretically be able to
serialize()the DOMDocument object, but that feels kludgy (if it’s possible at all). Exchanging proper XML looks like the way to go IMO.