refresh page problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asaaki
    New Member
    • Apr 2008
    • 2

    refresh page problem

    Hey,

    I'm generating on-the-fly reports, and each report is displayed with a link "Export to excel". Every time this link is clicked, I use Ajax to export the data in the report's table and save it as a file (report.xls), then I use window.location = "report.xls " to force the user to open or save the report in excel format.

    The report that's created on the server with the click is always accurate, but the one that the user can open/save is always a few reports old.

    I figured it was a caching problem so I added the headers like:
    header('Expires : Mon, 26 Jul 1997 05:00:00 GMT');
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Cache-Control: max-age=0');
    header('Cache-Control: no-store, no-cache, must-revalidate');

    I also changed from window.location ="report.xls " to document.locati on.href="report .xls". But no change.

    Any ideas?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Welcome to bytes.com!

    Try adding an extra parameter when accessing the Excel file, e.g.
    [code=javascript]window.location .href = "report.xls?d=" +new Date().getTime( );[/code]

    Comment

    • asaaki
      New Member
      • Apr 2008
      • 2

      #3
      Brilliant! Thank you!! :D

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You're welcome. Glad to help!

        Comment

        Working...