I have a modal dialog that allows users to generate a customized PDF. After they click a "Start" button, the page redirects with window.location to a controller, which then creates the PDF and returns it.
Because of how long it takes the PDF to return, I want to display a modal "Generating PDF" dialog that automatically closes once the PDF is complete and is returned.
The problem is I can't figure out how/when to execute that final function to close the "Generating PDF" dialog. Since the controller returns an application/pdf type, there is no document object event to attach to, right? What is the best way to do this?
Thank you for your responses. @PGill was on the right track. I've simplified his approach:
The solution here was to separate the Generation of the PDF from the Download of the PDF into 2 steps, so that between them, the modal dialog can be hidden.
which verifies it, retrieves the PDF rom the secure location and returns it.
ShowModalDialog();
$.ajax({
type: "GET",
url: 'GeneratePDFReportForDownload?' + params,
success: function (pdfkey, textStatus, jqXHR) {
HideModalDialog();
window.location = 'DownloadPDFReport?key=' + pdfkey;
},
async: true,
datatype: 'json'
});