By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 1,962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Refresh page after download complete

dlite922
Expert 100+
P: 1,584
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
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 397
Ask on the javascript / ajax board.
Oct 1 '08 #2

dlite922
Expert 100+
P: 1,584
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.