Ok so this is a general question about browser interaction and HTTP mechanims
Here is the scenario
- There is a very rich interface with a lot of buttons.
- The user clicks the button "generate the report"
- Then there is a loading time of approximately 15 seconds and then the "save file" dialogue box appears
- The user saves the files wherever he wishes and do further stuff.
Now I want to:
- Prevent him from interacting with the interface during step 3.
- At the end of step 3, trigger some specific javascript like showing a popup.
All this actually sums up to "how to detect the appearance of the download dialog box in javascript" because once this one is solved, this is easy to set up some mask during the file generation, and to do whatever is required once the event has been detected.
Unfortunately it seems like there is no way to launch a file download via Ajax because it lacks adequate handling for turning an XMLHttpRequest
into a save as dialog box. As a consequence you need to submit some form, but the mechanism is a little weird because although you submitted the form absolutely nothing happens in the DOM. Then the browser detects that response to the form submission is an incoming file and shows a download box instead of trying to display the file content, and once the user is done with the download box, the browser somehow manage to restore the interface in its previous state so that the user can keep on browsing (or at least this is how I understand the thing).