You could do it in PHP also. Take a look at Output Buffering: http://php.net/manual/en/book.outcontrol.php
That way you can send each part of the message as it happens, no JS required. On Fri, May 20, 2011 at 10:22 AM, Arian Stolwijk <[email protected]> wrote: > It sure would do a whole lot of stuff when it's running 30 minutes. > > Anyway to do a periodical request, you can do: > > // create an Request instance > var request = new Request({ > // some options > }); > > // Call the send method every 12 seconds > (function(){ > request.send(); > }).periodical(12000); > > > Alternatively you can do something like, and now between each request is at > least 12 seconds. It probably won't be a problem, but if you have request > which take longer than 12 seconds to respond, you'll end up with multiple > requests at the same time which is not wanted. > > request.addEvent('complete', function(){ > (function(){ > request.send(); > }).delay(1200); > }); > > > You can do it a little bit shorter this way, so you don't have to wrap it > in a new function: > > request.delay(12000, request); > or > request.periodical(12000, request); > > Stopping the timer can be done with clearInterval or clearTimeout. You have > to save the returned value of periodical or delay in a variable which you > can pass into one of those functions. > > Finally you probably want to use DOMReady instead the onload attribute on > the body element. > > > > > On Fri, May 20, 2011 at 6:07 PM, Mike <[email protected]> wrote: > >> I have a long php script running on the server. Right now, it runs >> (maybe a half hour) displaying NOTHING to the person running it. When >> it's done, it shows a list of everything that happened. I need to let >> the person running it know that it's running and where it is in the >> process as the script runs. I'm writing updates to a file called / >> backup/status.html. I'd like to kick-off the script (and keep it >> running), while at the same time continually displaying the contents >> of /backup/status.html. >> >> I think my answer lies in MooTools request.periodical. I just have no >> clue how to make that work.... and how to have it kick off the php >> script at the same time. >> >> So: kickoff /backup/script.php (and keep it running), at the same >> time continually grab and display the contents of /backup/status.html. >> >> I haven't even been able to get request.periodical to work at all. >> Here's what I tried: >> >> <script type="text/javascript" src="/backup/mootools13.js"></script> >> <script> >> var i = 0; >> var r = new Request({ >> url: '/backup/status.html', >> method: 'get', >> initialDelay: 100, >> delay: 100, >> limit: 1000, >> onRequest: function(){ >> $('result').adopt(new Element('li', { >> html: 'attempt: ' + (i++) >> })); >> }, >> onSuccess: function(r){ >> $('result').adopt(new Element('li', { >> html: 'success: ' + r >> })); >> } >> }).startTimer({ >> sleep: 2 >> }); >> >> >> (function(){ >> r.stopTimer(); >> $('result').adopt(new Element('li', { >> html: 'test complete.' >> })); >> }).delay(12000); >> >> </script> >> >> <body onload="r.start.Timer()"> >> <div id="result"></div> >> > >
