Downloading a File and Blobs
This fiddle is meant to provide an example of how you might download a file using jQuery and then leverage a Blob to give the client a clickable link.
HTML
<button id="download">Download</button>
<div id="output"></div>
JavaScript
var loc = 'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.js';
var url = '';
$('#download').click(function () {
$.get(loc, function (data) {
var datas = [data];
var blob = new Blob(datas, {
type: 'application/javascript'
});
url = URL.createObjectURL(blob);
$('#output').append('<a href="' + url + '" download>Save it!</a>');
})
.fail(function () {
// delete the file - probably a $.ajax
//$.ajax({
// url: 'url',
// type: 'DELETE'
//});
});
});