Created
December 8, 2021 08:24
-
-
Save nobodyplace/184cc07c19c65c9a47cd8b8dc6dc3997 to your computer and use it in GitHub Desktop.
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
$.post({ | |
url: 'makecsv.php', | |
dataType: 'json', | |
data: { | |
data: data | |
} | |
}).done(function(response){ | |
if(response != ''){ | |
let uInt8List; | |
let code = $('#result-output-encode').val(); | |
//エンコードしてBrobにセット | |
if (code === 'sjis') { | |
var codes = Encoding.stringToCode(response); | |
var shiftJisCodeList = Encoding.convert(codes, 'sjis', 'Unicode'); | |
uInt8List = new Uint8Array(shiftJisCodeList); | |
} else { | |
uInt8List = response; | |
} | |
const blob = new Blob([uInt8List], { type: 'text/csv' }); | |
//リンクを作成してクリック | |
const a = document.createElement('a'); | |
document.body.appendChild(a); | |
a.href = window.URL.createObjectURL(blob); | |
a.download = 'download.csv'; | |
a.click(); | |
} | |
}).fail(function( jqXHR, textStatus, errorThrown ){ | |
console.error( 'ERROR', jqXHR, textStatus, errorThrown ); | |
}).always(function(response){ | |
//do nothing | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment