Make page wait until something happens on the server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron Fude

    #1

    Make page wait until something happens on the server

    Hi,

    I have report that takes about 5-10 seconds to generate depending on the
    load. I want to show the user a progress bar while it is being generated and
    when it's done, forward the browser to the report.

    Any suggestions?

    Thank you!

    Aaron


  • Hywel

    #2
    Re: Make page wait until something happens on the server

    In article <3qIOc.669$HN5. 381@trndny02>, Aaron Fude says...[color=blue]
    > Hi,
    >
    > I have report that takes about 5-10 seconds to generate depending on the
    > load. I want to show the user a progress bar while it is being generated and
    > when it's done, forward the browser to the report.
    >
    > Any suggestions?[/color]

    Don't bother. You'll need to get some information about the report
    generation process to the client, which will probably involve refreshing
    the entire page.

    You could fudge it by just using an animated GIF, or use an animation
    that doesn't indicate how far through the process the report is but does
    give back some visual "feedback".

    --
    Hywel


    Comment

    • Robert

      #3
      Re: Make page wait until something happens on the server

      "Aaron Fude" <aaronfude@yaho o.com> wrote in message news:<3qIOc.669 $HN5.381@trndny 02>...[color=blue]
      > Hi,
      >
      > I have report that takes about 5-10 seconds to generate depending on the
      > load. I want to show the user a progress bar while it is being generated and
      > when it's done, forward the browser to the report.
      >
      > Any suggestions?
      >
      > Thank you!
      >
      > Aaron[/color]

      I do not know how workable this idea is, but here it goes anyway.


      The idea would be to have the report generate a graphic as it goes
      along then have the client javascript download the graphic ever so
      often.

      You would need to use a unique file name for each instance of the
      server program. You would have to figure out someway of telling the
      client what the name was. You would have to be sure your were not
      reading cached copy of the graphic. One way of doing this I think, is
      to append ?date & time to the name of the graphic file. You would have
      to figure out some way of deleting the graphics on the host.

      Maybe a note that the process will take ten to fiften seconds is
      enough. This isn't too long.

      Robert

      Comment

      • Grant Wagner

        #4
        Re: Make page wait until something happens on the server

        Aaron Fude wrote:
        [color=blue]
        > Hi,
        >
        > I have report that takes about 5-10 seconds to generate depending on the
        > load. I want to show the user a progress bar while it is being generated and
        > when it's done, forward the browser to the report.
        >
        > Any suggestions?
        >
        > Thank you!
        >
        > Aaron[/color]

        One of the ways of handling this is to open a window when the form is submitted,
        and close it once the report is completely loaded. It relies client-side
        JavaScript being enabled (of course) and on the browser's ability to respond
        appropriately to window.open() which many browsers will not do due to popup
        blockers.

        -- on the page used to initate generation of the report:

        <input type="submit" value="Generate Report" onclick="openSt atusWindow();">
        <script type="text/javascript">
        function openStatusWindo w() {
        if (window.open) {
        var throwAway = window.open(
        'status.html',
        'statusWindow',
        'width=400,heig ht=200'
        );
        }
        }
        </script>

        -- status.html:

        <html>
        <head>
        <title>Generati ng report... please wait</title>
        <script type="text/javascript">
        function holdFocus() {
        var t = setTimeout(hold Focus, 1000);
        window.focus();
        holdFocus.toStr ing = function() {
        return 'holdFocus();';
        }
        }
        </script>
        </head>
        <body onload="holdFoc us();">
        <p align="center"> Generating report... please wait</p>
        </body>
        </html>

        -- on the page containing the resulting report:

        <body onload="closeSt atusWindow();">
        <script type="text/javascript">
        function closeStatusWind ow() {
        if (window.open) {
        var w = window.open(
        'about:blank',
        'statusWindow',
        'width=400,heig ht=200'
        );
        if (w && !w.closed) {
        w.close();
        }
        }
        }
        </script>

        It's necessary to call window.open() again on the window named "statusWind ow".
        If you do not, you will not have a reference (handle) to it, and will not be
        able to close it. I tested it in IE6SP1, Netscape 4.78, Firefox 0.9.2 and Opera
        7.53 and it allowed me to open and close the window without holding a reference
        to it.

        --
        Grant Wagner <gwagner@agrico reunited.com>
        comp.lang.javas cript FAQ - http://jibbering.com/faq


        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: Make page wait until something happens on the server

          Aaron Fude wrote:
          [color=blue]
          > I have report that takes about 5-10 seconds to generate depending on the
          > load. I want to show the user a progress bar while it is being generated
          > and when it's done, forward the browser to the report.
          >
          > Any suggestions?[/color]

          Isn't that already done with the standard HTML form? The progress bar
          will be that of the browser, if it has one (or a similar feature).

          Or you use multi-document reponses like Bugzilla does.


          PointedEars

          Comment

          Working...