0

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

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by ~s.o.s~
0

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.

0

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.

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.