I'm downloading a file via window.location.href = '..path to server get method which returns file'
Here is my code on button click,
$(document)
.off('click', '#btnExportToExcel')
.on('click', '#btnExportToExcel',
function (e) {
e.preventDefault();
indicatorStart('Loading');
window.location.href = '/Index/ExcelReport';
indicatorStop();
});
Here is my indicatorStart()
and indicatorStop()
,
function indicatorStart(text) {
const $loader = $($.parseHTML(`<div id="loader" class="fade show">
<div id="loader-message" role="alert">${text}</div>
</div>`));
$('.page-content').append($loader);
}
function indicatorStop() {
$('#loader').remove();
}
loader works when I hook this method inside ajax lifecycle but not under normal get. Only file is getting downloaded correctly. Please assist on where I'm going wrong.