Tony Cowderoy wrote:
I know of two ways to bring .csv data into JavaScript:

1) the really crude way is to wrap it in a little bit of JavaScript code to make it a string, e.g.

      var csvData = "-----put your data here-----";

and then load it as a script in your web page. You've then got your data as a global (i.e. window level) variable. That assumes you can either modify the embedded server or that you have some way to filter the returned data (e.g. pipe it through sed);

I think I may be able to add a custom header to the log file but not a custom footer, so I'd have a problem adding the trailing "; But nice idea - I like the way you think!


2) the modern, fashionable, way is to use the XMLHttpRequest object in your JavaScript code to fetch the data from your server, like a fancy "AJAX" web application. Despite the object name, you don't have to treat the returned data as XML, you can just use it as a string. That means you don't need to do anything to the server. XMLHttpRequest will slurp all of the data in one go but, unless you have a huge amount of it, that shouldn't be a problem.

AJAX I have been looking at (there's an article in this month's Linux Format if anyone is interested) but hadn't appreciated that I could get something other than XML through it (as I say I'm stuck with CSV).

I googled before posting, and I'm sure I used pretty much the same query, but this time I found:
   http://www.kawa.net/works/js/jkl/parsexml-e.html
.. which seems to handle CSV data (I haven't tried it yet but it looks like a good start).

Can you modify the embedded server at all? JSON is very easy to output and can then be pulled straight into your page as a script, so that the JavaScript interpreter does the parsing for you.

Unfortunately not. The server gathers data and stores it as CSV. That's it.

Thanks for your help - I think I can see a light at the end of this particular tunnel!

--
Mark Rogers
More Solutions Ltd :: 0845 45 89 555


_______________________________________________
Peterboro mailing list
[email protected]
http://mailman.lug.org.uk/mailman/listinfo/peterboro

Reply via email to