How to download csv file using jquery?
How to download csv file using jquery ? I have group of records开发者_StackOverflow中文版 into jquery , so i need to export to csv and download using jquery .
Suggestions please..
OK, so there are (at least) three ways to download files:
- Build the file on the server, and set it to force download.
- Build the file on the client, and allow the user to download it via a special feature in Flash 10 without touching the server.
- 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.
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.
精彩评论