Re your update in the comment:
When the user clicks the link, I want to inform the user that the request is being processed; something like "Please Wait". And when the server side process is completed and the download starts, the "Please Wait" text should be invisible.
As I said in the comments, this is not as easy to do for a document download as it is for a web page.
A way that would be guaranteed to work is loading the document into an iframe (so that the whole page doesn't freeze), and polling the document's production status from the outside document using Ajax. That could be achieved half-way easily if you can make your document generating PHP script write the production status ("working" / "finished" or even a percentage value) into a text file that the Ajax call can query frequently. You would name the text file by a unique random key that would have to be created in the page containing the download link, and passed to the script generating the document.
You might be able, as you say, to query the IFrame's status somehow but I wouldn't know a defined way to do this: There will be no onload
event (because no document will be loaded - once the browser receives the information to expect a file download, it will pop up the "Save as" dialog and leave the IFrame's context completely). However it could be that the IFrame's src
property is set only when the document is produced (i.e. when the content-type and other headers have been sent) - you would have to try.