I did this with 2 librairies. MIT licensed: BinaryTransport and FileSaver . In this example, I upload a server file with Excel files.
HTML (in title):
<script src="/E1/js/jquery.binarytransport.js" charset="UTF-8"></script> <script src="/E1/js/FileSaver.js" charset="UTF-8"></script>
Javascript:
function ExportToExcel(urlExcel, fileName){ $("body").css("cursor", "progress"); $.ajax({ url: urlExcel, type: "GET", dataType: 'binary', headers:{'Content-Type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','X-Requested-With':'XMLHttpRequest'}, processData: false, success: function(blob){ $("body").css("cursor", "default"); saveAs(blob, fileName); }, error : function(result, status, error){ $("body").css("cursor", "default"); } }); }
For a custom loading animation, just call it where I change the cursor type in these lines:
$("body").css("cursor", "progress"); $("body").css("cursor", "default");
source share