I've encountered an issue with my AngularJS code for downloading an Excel file. While it works smoothly in Chrome and Internet Explorer, it fails to function in Firefox. The server response isn't presenting any problems. Here's the code snippet:
var did = "someid";
var url = '/downloadAsExcel';
$http({method: 'POST', url: url, data:did,headers: {'Content-type': 'application/json'},responseType: 'arraybuffer'})
.success(function(data, status, headers, config) {
var blob = new Blob([data],{type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
var fileName = headers('Content-Disposition').split(";")[1];
fileName = fileName.trim().split("=")[1];
var downloadName = (fileName != 'undefined') ? fileName : "DefaultName";
link.download = downloadName;
link.click();
})
.error(function(data, status) {
console.log("Something went wrong "+status);
});
Any assistance would be greatly appreciated.
Thanks, JK