• Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

109
Views
Is there a JavaScript equivalent of this where a callback can be used after form-submit - <iframe name="X"> + <form target="X"> + form.submit()?

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.

9 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.