[web] Possible to save xml file using javascript/html?

Started by
4 comments, last by markr 19 years, 4 months ago
Hi I'm wondering if it is possible to save an xml file with info, by using &#106avascript and/or html? thx
Advertisement
more info.

Short answer: yes. Long answer: maybe.
say i've made a form with a bunch of fields eg name, phone etc.

Then use &#106avascript to save that into xml file?"
Still no more information.

Save it where? Is this form just on the web someplace or on the local machine or even a firefox extension?
&#106avascript probably isn't up to this task without some form of extension system on the client browser. The best thing for doing this is the use of server-side scripting components, do you have this option available to you?
In some web browsers there exists an object which can be used to send HTTP requests to a server (independently of any page loading happening).

This is typically called XMLHttpRequest, and was originated by Microsoft. Mozilla has supported it for a while now and there are possibly some other browsers which do (Newer Opera and KHTML based browsers (Safari, Konqueror))

The exact method for creating this is slightly platform dependent. On IE on Win32, you need to use new ActiveXObject(somethingorother).

On most others, new XMLHttpRequest() should suffice.

Anyway, you can use this to send HTTP requests containing XML (or anything else, as it happens), and get the results back (in XML or anything else).

This can be used by client-side &#106avascript to make server requests.

HOWEVER it only works if the server is the same as the page was loaded from that the scripts are in. This is an important security feature.

You can use it to load/save things from a web page which is driven by client scripts (for instance a high score table).

Mark

This topic is closed to new replies.

Advertisement