Reputation: 8460
I have a Javascript call:
window.location.replace(instanceExtension(baseURL + "/AccountsReceivable/PrintStatementOfAccount?clientId=" + clientId, -1));
And the PrintStatementOfAccount() method takes a few seconds so I've added a mask to the page indicating that the PrintStatement is loading.
The ASP method is defined as:
public FileResult PrintStatementOfAccount(long clientId) { ... }
All works great, but I would like to disable the wait mask once the file returns. Any ideas on how I can achieve this?
Upvotes: 0
Views: 2180
Reputation: 1747
You cannot know from JavaScript whether the file is returned to the browser.
As a workaround instead of returning the file directly you split the process:
Upvotes: 1
Reputation: 78
You can pass token to the method and check for that token in the javascript.
var token = new Date().getTime();
$('#download_token_valueid').val(token);
$.download(path + "Print.ashx", 'Id=' + id + "&token=" + token);
fileDownloadCheckTimer = window.setInterval(function () {
var cookieValue = $.cookie('fileDownloadToken');
if (cookieValue == token)
finishDownload();
}, 1000);
function finishDownload() {
window.clearInterval(fileDownloadCheckTimer);
$.cookie('fileDownloadToken', null); //clears the cookie value
$.unblockUI();
}
Upvotes: 1