I am fully aware that there are many debates(and solutions) out there in terms of downloading files in javascript/jQuery, such as iFrame
, jQueryPlugin
.
There is Downloadify, which generates and force downloads files with Flash. There's also a demo available.
Or you could download the file using XHttpRequest ($.get in jQuery) and use data URIs.
You might want to try FileSaver.js which has support for all modern browsers.
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
saveAs(blob, "hello world.txt");