AJAX question: delayed update of messages

Hello,

I'd like to start a process on the server and update the client with information about the process, such as

'starting application ...' (wait 20 seconds) 'done'

and so on. Which strategy should I use? I have tried to use multiple render :update do |page| ... end, but this is not allowed (OK, obviously). And somthing like:

page.insert_html :bottom, 'textarea', 'before sleep' sleep(20) page.insert_html :bottom, 'textarea', 'after sleep'

did not work because both messages are sent back at the same time(?). So what could I do to update the browser's text? I know of periodically_call_remote, but that way I'd have to remember the state on the server side, right?

Patrick

Patrick Gundlach wrote:

Hello,

I'd like to start a process on the server and update the client with information about the process, such as

'starting application ...' (wait 20 seconds) 'done'

and so on. Which strategy should I use? I have tried to use multiple render :update do |page| ... end, but this is not allowed (OK, obviously). And somthing like:

page.insert_html :bottom, 'textarea', 'before sleep' sleep(20) page.insert_html :bottom, 'textarea', 'after sleep'

did not work because both messages are sent back at the same time(?). So what could I do to update the browser's text? I know of periodically_call_remote, but that way I'd have to remember the state on the server side, right?

Patrick

The periodicalUpdater from the prototype js library might be what you want. See Prototype API Documentation | Ajax.PeriodicalUpdater (Deprecated URL) and http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000959

backgroundrb? not sure

Roger Pack wrote:

backgroundrb? not sure

That's a cool thing! Not really solving the problem I have here, but it will solve other problems!

Thanks,

Patrick

Patrick Gundlach wrote:

Roger Pack wrote:

backgroundrb? not sure

That's a cool thing! Not really solving the problem I have here, but it will solve other problems!

Thanks,

Patrick

I googled with the keyword "AJAX push" and it came with a few interesting results What about this: http://home.flowdev.de/wordpress/index.php (Look for RTRails) http://www.lightstreamer.com/ http://www.pushlets.com/

Danny Hiemstra wrote:

Patrick Gundlach wrote:

Roger Pack wrote:

backgroundrb? not sure

That's a cool thing! Not really solving the problem I have here, but it will solve other problems!

Thanks,

Patrick

I googled with the keyword "AJAX push" and it came with a few interesting results What about this: http://home.flowdev.de/wordpress/index.php (Look for RTRails) http://www.lightstreamer.com/ http://www.pushlets.com/

Hello Danny,

thanks for the keywords, somehow these didn't come into my mind. I have not implemented anything yet, but this will guide me in the right direction. Thans again!

Patrick

You might want to check out the juggernaut gem and associated plugin. In short, it sticks a little flash app into your page which ultimately allows you to _push_ from the webserver to the client browser. There are various options for identifying clients and channels so the messages you push can be as broad or restricted as you like. Typically you end up pushing javascript to the client to update the state of the page.