Jquery File download ($.fileDownload)
function exportToExcelTest() {
var region = $('#ddlRegion').val();
var hrinfo = $('#hrinfodropdown').val();
if (region != null) {
$('#ExportOptions').modal('hide');
$.blockUI({ message: '<h1>Please wait generating excel data...</h1>' });
//$.blockUI({ message: '<h1><img src="../Images/ajax_loader_blue_350.gif" /> Just a moment...</h1>' });
$.blockUI({ css: { backgroundColor: '#f00', color: '#fff'} });
var myData = region + ':' + hrinfo;
$.fileDownload('Excel.ashx', {
httpMethod: "POST",
data: { data: myData },
successCallback: function (url) {
//$("div#loading").hide();
//alert('ok');
//response.setHeader("Set-Cookie", "fileDownload=false; path=/");
$.unblockUI();
},
prepareCallback: function (url) {
//alert('ok');
//response.setHeader("Set-Cookie", "fileDownload=true; path=/");
$.unblockUI();
},
failCallback: function (responseHtml, url) {
//alert('ok');
// $("div#loading").hide();
// alert('Error while generating excel file');
//response.setHeader("Set-Cookie", "fileDownload=false; path=/");
$.unblockUI();
}
});
}
else {
alert('Please select a region....');
return false;
}
}
https://stackoverflow.com/questions/13853300/jquery-file-download-filedownload
https://blog.csdn.net/weixin_41029960/article/details/82585082?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_title-1&spm=1001.2101.3001.4242
https://stackoverflow.com/questions/52495935/how-to-download-a-file-from-java-controller-to-javascript
留言
張貼留言