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

In our current project, we provide a PDF file that can be customized by the user through the HTML form that he represents. Creating PDFs dynamically takes a few seconds, and I would like to visualize this, for example. disabling the submit button before starting the download. Unfortunately, I could not find a way to detect when the download * begins. Therefore, I do not know when to turn on the submit button again.

I already tried to specify the IFrame as the target of my HTML form, hoping the event onloadwould fire. However, this is not the case, probably because the PDF was sent with the title " Content-disposition: attachment" and it does not actually load in the IFrame.

The only solution I can think of now is to create a PDF file for the temporary file on the server, which I would like to avoid.

*) Let me clarify this: I would not need to know if the download was completed or even if it really started. I would like to determine the point at which the browser will ask the user whether to open or save the file. I assume this happens when the browser receives the HTTP header.

+5
source share
3 answers

, , - , 0 . , javascript - , .

: . . " ", " ", "", "". , AJAX.

+2

, AJAX , , /id/what javascript, window.location - download.php? id = x ( , ), .

+4

() . , . , Ajax, . http://www.jquery.com/ .

0
source

All Articles