Rose
Rose

Reputation: 61

How to download csv file using jquery?

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..

Upvotes: 1

Views: 2886

Answers (2)

Doug Neiner
Doug Neiner

Reputation: 66191

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.

Upvotes: 2

Mark
Mark

Reputation: 33571

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.

Upvotes: 0

Related Questions