SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru quenting's Avatar
    Join Date
    Dec 2002
    Location
    Switzerland
    Posts
    735
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sending data to browser before script finished

    Hi,
    Let's say i have a big script that takes up to 10 seconds to execute.
    I'd like to send some part of the html file to the browser at the beginning of the script so that something is displayed (like a "be patient" sort of phrase, maybe an animated gif or something) and once the big part of the script is run send the "end" of the html file.

    Can i do this in php ? Using output buffering functions ? Something else ?

    Another case of long time process for which one could want some temporary data displayed until it's done is file uploading.
    Is it possible to print something on the screen to make the user patient while the upload takes place (i think an exact load bar is impossible, but a simple gif ?) ?
    Maybe that's more of a javascript question than php since the process starts on the client...

    Thanks for any ideas / experiences
    Quentin
    The largest message boards on the web !
    unblog.fr, hosting 700000 french blogs

  2. #2
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can use ob_flush() to send the info to the browser, however, some browsers will not show the page until it is completely loaded.

    as for the uploading one, javascript would be a good way to do it, once the form is submitted, you show an 'uploading...' image on the same page, then after the upload is complete the broswser will go to the next page.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •