Sunday 15 September 2013

Javascript/JQuery Local File System -



Javascript/JQuery Local File System -

i have problem regarding creating xml file via web browser , beingness able read/write it. multiple browsers have issues , cant seem find solution works.

i creating cms displays xml info in fields. want read values of input elements , overwrite xml file using javascript or jquery.

the xml file stored on web server , client pc's access cms via webpage on server , reading/writing xml.

the code below gives thought of im trying do:

var xmldoc = new activexobject("microsoft.xmldom"); var fso = new activexobject("scripting.filesystemobject"); var filename ="xml.xml"; //<---- in current directory on web server. var file = fso.createtextfile(filename, true); file.writeline('<?xml version="1.0" encoding="utf-8"?>\n'); file.writeline('<seating_plan>\n'); var table = document.getelementbyid("table_assoc"); var rcount = table.rows.length; (var = 1; < rcount; i++) { var id = table.rows[i].cells[0].children[0].value; var deptcode = table.rows[i].cells[1].children[0].value; var name = table.rows[i].cells[2].children[0].value; var role = table.rows[i].cells[3].children[0].value; var desc = table.rows[i].cells[4].children[0].value; var image = table.rows[i].cells[5].children[0].value; var asdir = table.rows[i].cells[6].children[0].value; file.writeline('<person id="' + id + '"><dept>' + deptcode + '</dept><name>' + name + '</name><description>' + desc + '</description><role>' + role + '</role><image><image href="' + image + '"/></image><associatedir><associatedir href="' + asdir + '"/></associatedir></person>'); } file.writeline('</seating_plan>'); file.close(); }

however, works when accessing webpage on local scheme rather server eg. via: "file://c:..." rather than:

http://localhost/admin.html

what best way this?

any help appreciated. many thanks! aj

i suspect you're misunderstanding here:

var fso = new activexobject("scripting.filesystemobject"); var filename ="xml.xml"; //<---- in current directory on web server.

the web browser can't access server's file system. activex object may allow file scheme access on current host, it's not going allow on other hosts. if there no errors , browser allowing activex object interact local file scheme i'll bet it's creating file on local file system. (in whatever happens current working directory browser process, since no directory specified.)

to interact files on server's file system you'll need utilize server-side code.

javascript jquery html ajax xml

No comments:

Post a Comment