As an alternative to polling the client, as Ryan describes, you could
 consider piggy-backing the status updates on the back of other ajax
 responses. Which way you go depends entirely on the nature of your app, in
 particular:

1. how frequently it generates ajax traffic anyway
2. how long the server-side process is going to take

If the server-side process takes, say, 20 seconds, polling is a good choice.
If it'll take half an hour, piggy-backing is not going to hammer your server 
anything like as much.

The X-JSON header in Prototype, combined with Ajax.Responders, makes an
excellent infrastructure for the piggy-backing approach.

Dave

On Thursday 15 February 2007 18:03, Ryan Gahl wrote:
> Short of using comet (google for "cometd" for an explanation), this is a
> manual type of thing...
>
> 1. Initial request goes to server, server responds "starting step 1"
> 2. Client gets message, immediately sends another request to server, server
> responds "still in step 1, dude, chill out..."
> 3. Client gets message, repeats calls until server says "alright already,
> I'm done, here's your damn data"
>
> and you show nice message for each cycle... you can also implement a
> progress bar if you want. But the bottom line is, with standard AJAX, you
> need to program it yourself.
>
> On 2/15/07, Neil Ravo (Manhatten Project) <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > More a pure Ajax question that SAU, but is there a way you can
> > increment status messages back to the client when calling a long
> > running request? i.e. if I have a request which calls a remote page,
> > which in turn sends back a message after each function has completed
> > can you incrementally tell the client that "function 1 has
> > finished" (while the system has moved on to step 2), "function 2 has
> > finished" etc.  I know I can send back simple messages on a page
> > complete via standard Ajax status calls but I was wondering if it was
> > possible using headers or some other mechanism to incrementally tell
> > the client what is going on.
> >
> > Cheers
> >
> > Neil

-------------------------------------------------------

-- 
----------------------
Author
Ajax in Action http://manning.com/crane
Ajax in Practice http://manning.com/crane2
Prototype & Scriptaculous Quickly http://manning.com/crane3

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to