jQuery Table to CSV export

前端 未结 5 2201
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 13:18

I\'m using the jQuery Table to CSV Plugin. I\'ve altered the popup so that it tells the browser to download a CSV file.

It was:

function popup(data)         


        
5条回答
  •  盖世英雄少女心
    2020-11-27 14:09

    Not compatible with all browsers, but no server side needed! Try the code below using JSFiddle and tell us if it is running in your browser.

    $('')
        .attr('id','downloadFile')
        .attr('href','data:text/csv;charset=utf8,' + encodeURIComponent(data))
        .attr('download','filename.csv')
        .appendTo('body');
    
    $('#downloadFile').ready(function() {
        $('#downloadFile').get(0).click();
    });
    

提交回复
热议问题