1

I changed an XMLDocument localy using javascript. How do I save it on the server? I tried the following:

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();

In the php-file I wanted to do something like this:

$file = "./path/to/xmlfile/xmlfile.xml";
$dom = new DOMDocument();
$dom = $_REQUEST['newdocument'];
$dom->save($file);

This does not work, however.

Is there an easy way to save the XMLDocument object the php-file recieves?

1 Answer 1

1

You should try sending the XMLDocument with a POST as a multipart.

Sign up to request clarification or add additional context in comments.

9 Comments

Do you mean using "POST" instead of "GET"?
Yes! Please read about the limitations of GET method and POST method. stackoverflow.com/questions/266322/…
Ok, so I changed that to POST, put the data into the send method, and changed the php-file to use POST, too. Setting $dom=$admin returns an fatal error, though, when using $dom->save($file), namely "Call to a member function save() on a non-object".
I also added this: xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
add a var_dump to the php file. Post here what it prints.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.