469,356 Members | 2,641 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

Refresh page after download complete

dlite922
1,584 Expert 1GB
Hey guys been a while since I needed your help.

I've got a reporting system (yes same old one) , one button runs the report and builds the html table into the page all nice with CSS, etc, the other button produces a CSV output. I set the header variables (content-type, etc...) so that the user gets the Open/Save/Cancel prompt instead of outputing the CSV data.

The problem:

Since some of these reports take a long time, When a button is clicked I display an ajax loader. It works fine in case of the display to screen button because the page is refreshed, but in case of the export, the dialogue is displayed to download the file and the ajax loader image is still spinning on page.

How can I forward the page after the CSV page is displayed? Since in this case the page is actually refreshed as well (goes to the page that outputs the CSV) but of course to the browser it doesn't "display" the URL and hence change the look of the page, instead it displays the dialog.

I'm not sure i'm explaining this right so let me know if you don't understand. Here's the two buttons:

Expand|Select|Wrap|Line Numbers
  1. ############## SOME OF MY JS FUNCTIONS ################
  2.  
  3.  
  4. /** SUBMIT THE MAIN FORM **/
  5. function submitGlobalForm()
  6. {
  7.     document.forms[0].submit();
  8.  
  9. }
  10.  
  11. /** PAGE LOCATION \ REDIRECTS **/
  12. function changeURL(url)
  13. {
  14.     document.location = url;    
  15. }
  16.  
  17. /** CHANGE DISPLAY VALUE OF AN ELEMENT, USED FOR AJAX LOADING IMAGE **/
  18.  
  19. function toggleDisplay(docID,displayValue)
  20. {
  21.     if(document.getElementById(docID) != null)
  22.     {
  23.         document.getElementById(docID).style.display = displayValue;    
  24.     }    
  25. }
  26.  
  27. ###### H T M L (minus containers, other elements, etc) #########
  28.  
  29. <input type="submit" name="pageAction" id="runReportBtn" value="Run Report" class="btn" onclick="toggleDisplay('runBtnLoaderImage','block'); toggleDisplay('reportTable','none');toggleDisplay(this.id,'none')" disabled="disabled" />
  30.  
  31. <img id="runBtnLoaderImage" class="noDisplay" src="images/loaderSmall.gif" alt="Loading..."/>
  32.  
  33.  
  34.  
  35. <input type="submit" name="pageAction" id="exportCSVBtn" value="Export CSV" class="btn" onclick="toggleDisplay('exportBtnLoaderImage','block'); toggleDisplay('reportTable','none'); toggleDisplay(this.id,'none'); changeURL('report.php');" disabled="disabled" />
  36.  
  37. <img id="exportBtnLoaderImage" class="noDisplay" src="images/loaderSmall.gif" alt="Loading..."/>
  38.  
  39.  
  40. //Note: Ignore the the &nbsp; in the elements, that's not in my code, don't know why it shows here. 
  41.  
Thanks guys!
Yours,



Dan
Oct 1 '08 #1
2 6284
David Laakso
397 Expert 256MB
Ask on the javascript / ajax board.
Oct 1 '08 #2
dlite922
1,584 Expert 1GB
Ask on the javascript / ajax board.
Thanks, yeah I should have, I was sleepy and tired.

Can a moderator move it? That would be better than having it in both places.


Thanks,


Dan
Oct 1 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Steve | last post: by
43 posts views Thread by dan baker | last post: by
1 post views Thread by ACaunter | last post: by
3 posts views Thread by Harold Crump | last post: by
10 posts views Thread by Piotr Nowak | last post: by
6 posts views Thread by Chris Beall | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.