Is there a way to detect the start of a download in JavaScript?

后端 未结 3 963
抹茶落季
抹茶落季 2021-01-13 10:48

In our current project we are providing a PDF download that can be customized by the user through an HTML form he submits. It takes several seconds to dynamically generate t

3条回答
  •  爱一瞬间的悲伤
    2021-01-13 10:59

    If I was you I would do an AJAX call to the server with the information, generate the file, then return the file name/id/whatever back to the javascript, which then makes window.location something like download.php?id=x (but the file was already generated, so it is just setting the headers and reading it out) at which point you can re-enable the submit.

提交回复
热议问题