I have a generic JS file-download function in an application which uses this template to send http POST requests to web handler (ASHX) and download files -
downloadFile(url) {
// other code ...
// creates these iframe & form element dynamically
<iframe name="X" id="X" onload="showErrorInCustomDialogBox()">
<form target="X" method="post" action="*encodedURL*" ></form>
// this is called after iframe & form elements are created
form.submit();
}
On a click of a button in the application, this code gets called and a dialog box opens up asking user a location to download the file. I want to call a function after the user has saved the file.
How can I achieve this same functionality using JS/jQuery and be able to call a function after file-download finishes? What options do I have here? I have tried using XHR but it didn't work out (see my other question).
If something's possible using these iframe
+ form
elements that would be preferable because the way things currently work, when any error occurs during the download, the error message is loaded in the iframe
, which is displayed in custom dialog box in the application.