All,
I have an HTML page that contains a form.
When the user completes the form and clicks “Submit” – the form posts the user’s inputs to a PHP page.
That PHP page processes the inputs and returns the user’s results as an attachment.
So far – everything works OK – the user clicks “Submit”, the browser’s progress bar starts to “spin”, and after a few seconds, the attachment is downloaded.
However, in the browser – the user is still on the form page. That’s OK with me.
So – here’s my question. Ideally, when the user clicks “Submit” – I would like to update the form page to indicate that the “process” is in progress. E.g.,
- disable the submit button to prevent redundant clicks
- display a “downloading” message and a “spinner”-type graphic
Then, when the download is complete – I’d like to capture that event so that I could re-enable the submit button and remove the downloading message.
Is this possible?
Or – is my initial set-up just wrong? Is there a better way to do this? (That is – have a form that calls a PHP page, have the PHP page return an attachment, and then return control to the calling page?)
Thanks in advance for your advice and insight!
Use javascript to open up the download in a new window. So don’t return the download in the POST request, simply let the page reload and put some javascript on the page that will open up a new window that will call your PHP script that will download the file.