2
votes

I've got a difficult one where I have one system generating CSV files to a directory on my web server, but I need to display that data using dataTables /jquery. I can't change the CSV data into JSON because other systems consume that data right now.

I've tried using XMLHttpRequest to get my csv file & fire it through a callback conversion function before providing the converted data to dataTables. The problem I find is that invariably the GET for the CSV isn't complete before the DOM is ready so I get an empty dataTable. I've not seen a way to tell dataTables to reload the data - maybe I've missed that??

I've taken a look at using fnServerData in the dataTable to replace the XMLHTTPRequest. But in this case I don't seem to be able to get hold of the raw data - it seems to be trying to interpret it as JSON all the time.

  • Has anyone handled server side CSV data going into dataTables successfully?
  • Any views on the best approach to continue with - XMLHttpRequest & maybe some kind of refresh call to dataTables??
  • How can I get the raw CSV data if I use fnServerData?? I should also mention my CSV includes a header row so I've got to remove that regardless.
1
Add a second page to the server which serves the same data as JSON rather than CSV. - Stefan Majewsky

1 Answers

1
votes

In the dataTables forum some has posted a message about how they have been able to load a CSV file into the dataTables using the csv2table plugin.