Jump to content

Data from Form->Javascript->XML File?


spacefire

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...