Re: Sending data to browser periodically

From: Date: Fri, 06 Oct 2000 14:47:59 +0000
Subject: Re: Sending data to browser periodically
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-18892@lists.php.net to get a copy of this message
Hi Clive! On Fri, 06 Oct 2000, Clive Hughes wrote: > Hi, > > I have a headache due to the 5 minute timeout limitation of IE. My query takes (you've > guessed) longer than 5 minutes to perform. It is a query that summarises over 2 million rows from > an Oracle 8i database. I am developing an intranet site so the user is prepared to wait 10 mins for > this report to run. > > The question is: is there a way of sending something to the browser periodically (so that IE > thinks that all is well!) until I am ready to send the table data back? > > Thanks for any help You can have something like this: Client Server ------------------------------ i. Send Query[1] ---> ii. <---- Register ticket + 'Location: <control page>' /HTTP 202 /JS iii. JS timeout to callback to server Send Query[2] + ticket ---> iv. <---- results [1] -- you send the needed data to be processed by PHP, then return to the client a `ticket' information (may it be by setting a cookie or dynamic generated JS. [2] -- Display 'Processing, have patience, don't drink coffee, it kills your heart, don't smoke, the air is already poluted. I dunno, have some candies' plus: <script> function callback_hoock (ticket) { alert ('Your clothes are washed and dried....'); self.location.replace('http://server/php_crunker.php?ticket='+ticket); } setTimeout('callback_hook',<?=$timeout?>,'<?=$ticket?>'); </script> The only problem to solve now is how to cache the results, to serve them when the client comes back with our granted ticket. You can choose to write/marshall them to a file, say something like '/tmp/ticket_123k12h3k23123h', then readfile/unmarshall it to the client and delete the file on step iv. All this is based on the assumption the client has a JS enabled browser, and as you already mentioned you can `educate' them, I think it should work. -- teodor

« previous php.general (#18892) next »