このようにしてみてください
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://www.experts-exchange.com/questions/28713105/Jquery-fileDownload-successcallback-not-working.html
私はそれがあなたのために働くことを願っています。