Capture reload/endrequest event after server redirect to download file

Posted by Prutswonder on Stack Overflow See other posts from Stack Overflow or by Prutswonder
Published on 2010-03-31T07:58:39Z Indexed on 2010/03/31 8:13 UTC
Read the original article Hit count: 367

Inside a webpage I have an Excel download button, which redirects to a webpage that serves the requested Excel file via the application/ms-excel MIME type, which usually results in a file download in the browser.

In the webpage, I have the following jQuery code:

$(document).ready(function () {
    $(".div-export .button").click(function () { setBusy(true); });
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () { 
        setBusy(false);
    });
});

Which displays a busy animation while the user waits for the Excel file to be served.

Problem is: The animation doesn't end (setBusy(false);) after the file download, because the endRequest event doesn't get fired, probably because of the server redirect.

Does anyone have a workaround for this?

Edit: The download button is handled in an UpdatePanel.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript