spacefire Posted May 9, 2007 Share Posted May 9, 2007 HiI'm trying to figure out how to do this: information that is taken from an user input form into a Javascript code and formatted needs to then be written to an XML file stored on the site (which actually gets entries edited or new entries appended to it)I understand Javascript itself cannot write to XML files?Is there a program that would do so that I can call from the script?Thanks! Link to comment Share on other sites More sharing options...
boen_robot Posted May 11, 2007 Share Posted May 11, 2007 Well, you can make an xmlHttpRequest() - the so called AJAX - for that, but with it, you can only call on a page, not send POST data with it. You could append the contents of the XML file into the query string, but this puts a limit on the lenght of the XML file (something like 100 characters I think). The only way to upload a full XML file is to use the POST method, and for that, you must submit the form, in turn causing a page reload and using a S3L to validate and save the file. Link to comment Share on other sites More sharing options...
jesh Posted May 11, 2007 Share Posted May 11, 2007 Well, you can make an xmlHttpRequest() - the so called AJAX - for that, but with it, you can only call on a page, not send POST data with it.Sure you can:xmlhttp = YourGetXMLHttpRequestFunctionHere();data = "key1=value1&key2=value2&key2=value3";// or// data = "xml=<node><subnode>hello</subnode></node>";xmlhttp.open("POST", url, false);xmlhttp.setRequestHeader("Content-Type", "application/x-www-urlencoded");xmlhttp.setRequestHeader("Content-Length", data.length);xmlhttp.setRequestHeader("Connection", "close");xmlhttp.send(data); But the fact remains, spacedout, that you can't generate files with javascript. You have to do that on the server using some server-side language like PHP, ASP(.NET), CF, etc. Link to comment Share on other sites More sharing options...
spacefire Posted May 14, 2007 Author Share Posted May 14, 2007 thanks for the repliesIs there a ready-made php script that I can call from javascript to append/edit an xml - or regular text file on the server? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.