Javascript xml save issue

I want to change some data about a server side XML file using javascript.

I am using the following code

var xh;
if(window.XMLHttpRequest)
{
    xh=new XMLHttpRequest();
}
else
{
    xh=new ActiveXObject("Microsoft.XMLHTTP");
}
xh.open("get","books.xml",false);
xh.send("");
var xdoc=xh.responseXML;
var x=xdoc.getElementsByTagName("title");
x[0].getAttributeNode("lang").nodeValue="zh";
xh.save("books.xml");

      

but its not working

Thanks in advance, Guru

+2


a source to share


1 answer


You cannot edit files on the server using JavaScript (unless your server is running Node.js, but that's a completely different story). JavaScript is a client-side language; you need a server-side language if you want to write to a file.



0


a source







All Articles