I am trying to circumvent the whole "javascript can't read files, that's server-side" thing.

basically i have a order form with a table inside it. I want to be able to load the rows of the table dynamically when the page loads. I am trying to get the "product" information from a file so I don't have to use a million JS variables.

everyone keeps saying you can't read a file from the server. so is it possible to just save it as an html doc and parse it out in the javascript?

if so, how?

thanks in advance

david

Using the Javascript XmlHttpRequest object ( all common modern browsers have it, although it sometimes has a different name ), you can issue a HTTP request to any page or program on your server, and then process XML replies as a DOM structure, or plaintext replies, as plaintext ( the reply from a page is the page content ). So yes, you can; research XmlHttpRequest, and AJAX. If you use the XML method, you avoid having to do any kind of parsing - the DOM is a ready-formed structure that's quite easy to work with.

Thanks for the help. Unfortunately, my teacher has limited this particular assignment to DOM Level 0 and that object is Level 3. Maybe in another assignment.

If you don't want server interaction, you can of course load the data from a local XML file and render it.

This question has already been answered. Start a new discussion instead.