Topics: Developer Forum, User Forum
Aug 30, 2012 at 5:07 PM

Currently I initiate the php which creates the excel spreadsheet using javascript and windows.location.href, and in the php, I use the following:


 and it works very well. The excel spreadsheet downloads to the users desktop. At times, depending on the users request for the spreadsheet, this can take a long time. I would like to post an image to tell them to please wait, and then remove the image after the spreadsheet has been created.

What I cannot figure out is how, in javascript, to detect when the spreadsheet has been created.

I have tried using an ajax routine, instead of windows.location.href, but I think the internal code of the spreadsheet is returned as the response, and the spreadsheet is not downloaded.

It is necessary to have the spreadsheet downloaded (user reasons), rather than have it created in some server location and then accessed. Any ideas as to how to detect when the spreadsheet is available for download, so that I can then remove the "please wait" image in javascript?

FYI, as you can probably guess, I am relatively new to this programming environment (javascript,php).

Aug 31, 2012 at 12:49 PM

 - Add a periodical check, in javascript, looking for a cookie with a unique name / value, in your first page (where your user click to have the Excel file).

- With the request to have the file, add the chosen name/value

- In your script who made the excel file, add the cookie, same name / value the javascript is looking for (and added to your request).

When the server send the file, the cookie go with it, the browser show the download dialog box, in same time, the javascript script see the cookie and can remove the 'please wait'.