in your ajax request file

<?php
ini_set('output_buffering',0); // make sure the output_buffering directive 
is not set high
ob_start(); // before anything is echoed to the screen

for($i=0;$i<10;$i++)
{
    echo('<li>Printing Line '.$i.'</li>');
    ob_flush();
    flush();

    sleep(1); //  sleep for one second
}

?>
this will output a line every second for 10 seconds

Hope this helps

P.S if you use ob_gz_handler this may not work (untested using it)


Alex Mcauley
http://www.thevacancymarket.com


----- Original Message ----- 
From: "joe t." <[email protected]>
To: "Prototype & script.aculo.us" <[email protected]>
Sent: Friday, December 11, 2009 1:00 AM
Subject: [Proto-Scripty] Re: Progressive update messages from single request


david:
The buffer/flush path seems to be where this solution is heading.
Don't ask me why, but iframes rub me the wrong way. With the evolving
needs for more streamlined connections, iframes feel like soggy
bandaids to me. Given they have a place where nothing else seems to
work (Ajax-ish file uploads), but i'd prefer to steer away from them
in this case if i can.

TJ:
That seems like a fairly solid idea. Same general concept of having a
second request object checking in on progress that the server reports
back, it just gets it from a relatively more reliable source (instead
of $_SESSION).

Alex:
Could you elaborate a bit, or point me to where i can follow up on
that? i'm intrigued, but i'm not deeply familiar with using the output
buffer effectively.

Thanks for the replies!
-joe t.


On Dec 10, 3:45 am, "Alex McAuley" <[email protected]>
wrote:
> I noticed you were using PHP on the server side ... you can also use 
> output
> buffering to achieve this in one request
>
> Alex Mcauleyhttp://www.thevacancymarket.com
>
> ----- Original Message -----
> From: "T.J. Crowder" <[email protected]>
> To: "Prototype & script.aculo.us" 
> <[email protected]>
> Sent: Thursday, December 10, 2009 8:38 AM
> Subject: [Proto-Scripty] Re: Progressive update messages from single 
> request
>
> Hi Joe,
>
> It seems to me the simple way to do this is have the first request
> initiate a process on the server that keeps running when the request
> completes; the request returns an indicator of the current status and
> an identifier for the action.
>
> Your subsequent requests supply the identifer, which allows the server-
> side page to check the progress of the ongoing work matching that ID
> and report back the (new) status.
>
> People use things like this for showing progress bars for file uploads
> without using Flash, that kind of thing.
>
> HTH,
> --
> T.J. Crowder
> Independent Software Consultant
> tj / crowder software / comwww.crowdersoftware.com
>
> On Dec 9, 4:11 pm, "joe t." <[email protected]> wrote:
> > i think i've seen examples of this, but can't recall where, and could
> > use some guidance.
>
> > Obviously it's easy to handle a 1:1 Request/Response
>
> > How can i do a true 1:many process? For instance:
> > Client takes a single action which requires the server to perform 3
> > tasks:
> > * Query database
> > * Generate PDF
> > * Generate email, attach PDF, and send
>
> > How can i respond to the client as EACH task is accomplished without
> > ending the request chain?
> > "Looking up your data . . ." (time-based dots as delay indicator)
> > "Creating PDF . . ."
> > "Email sent" (or failed, as the case may be)
>
> > Is this done with HTTP 2xx headers? Recursive callbacks? If anyone can
> > point me in the right direction (which include samples), i'd be
> > grateful.
>
> > Thanks.
> > -joe t.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/prototype-scriptaculous?hl=en.
>
>

--

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to 
[email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



--

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.


Reply via email to