$( ".downloadzip" ).click(function() {
alert( "Handler for .click() called." );
var zip = new JSZip();
zip.file("Hello.txt", "Hello World\n");
/* var img = zip.folder("images");
img.file("smile.gif", imgData, {base64: true}); */
zip.generateAsync({type:"blob"})
.then(function(content) {
// see FileSaver.js
saveAs(content, "example.zip");
});
});
And trying to download after clicking a button but nothing is happening. Is there something wrong I am doing? I am not seeing any errors in the console
Well for starters, start using a version of jQuery that isnt over a decade old. The current release of jquery is 3.3.1. Will dig into JSZip for a second…
So I dont understand how it wouldn’t be throwing an error into the javascript console if this function is missing and undefined. You’re sure nothing appears in the console?
Which means your console is filtering error messages out, i’m guessing. It’s definitely the saveAs line causing it, obviously.
Googling around for advice on the matter… assuming you’re using Chrome, make sure you havent got any filters on (next to the filter box, it should say “All levels” and if you drop down the arrow next to it, it should have check marks next to everything)
It was firefox and Microsoft Edget not showing error. Chrome did show it now:
index.html:106 Uncaught (in promise) ReferenceError: saveAs is not defined
at index.html:106
I am wondering, where is this FileSaver.js is available? In the documentation they didn’t mention about it except in the comments. By any chance, you saw it somewhere?