Use js  instead of php script for extracing csv data

here is an example of how to get the csv extraction done on client side.
code from http://stackoverflow.com/questions/17836273/export-javascript-data-to-csv-file-without-server-interaction