Created
February 6, 2015 06:57
-
-
Save pradeepn/264b953ca15777fb64b4 to your computer and use it in GitHub Desktop.
Client File Download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//$.borwser plugin | |
//$.fileDownload plugin | |
downloadCsv: function (filename, array, dilem) { | |
var csvString = _JSONtoCSV(array, dilem); | |
console.log(csvString); | |
if ($.browser.msie == true) {//HTML5 Download attribute not available in ie | |
$.fileDownload('/downloadcsv', { httpMethod: "POST", data: { CsvString: csvString, FileName: filename} }); | |
} | |
else { | |
var a = document.createElement('a'); | |
a.href = 'data:attachment/csv,' + escape(csvString); | |
a.target = '_blank'; | |
a.download = filename; | |
a.style = "visibility:hidden"; | |
document.body.appendChild(a); | |
a.click(); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment