1

How to download csv file using jquery ? I have group of records into jquery , so i need to export to csv and download using jquery .

Suggestions please..

Rose
  • 61
  • 2
  • 5
  • 8

2 Answers2

2

OK, so there are (at least) three ways to download files:

  1. Build the file on the server, and set it to force download.
  2. Build the file on the client, and allow the user to download it via a special feature in Flash 10 without touching the server.
  3. Encode the info into a Data URI or use the IE specific variation to save a client side file. (This approach has a ton of limitations and issues)

Since you said you have the CSV in jQuery (I assume you mean JavaScript) here I would suggest you look into the library I wrote, Downloadify, for use in situations like this. The Demo page or documentation should be able to get you going.

Downloadify is a JavaScript interface for the Flash 10 feature. As with any technology, I suggest you also implement a variation fallback on the server for users w/o Flash 10.

Doug Neiner
  • 65,509
  • 13
  • 109
  • 118
0

jQuery cannot create a downloadable file. You need to do this server side. You can use a language like PHP or you can try putting jQuery on the server through one of the server side JS implementations.

Mark
  • 32,293
  • 33
  • 107
  • 137