views:

58

answers:

3

I know it might be simple to write some polling JS that asks the Rails application if it has completed a background job. But I wonder if anyone has already packaged up this functionality as a plugin.

Basically, I have a few delayed_jobs running, and am looking for a plugin that will poll the server for completion of a particular job, then activate a callback when it finds that the job is complete.

Any ideas anyone?

Berns

A: 

Have you check out Comet?

simianarmy
A: 

There are probably few plugins that do this because it's often a very application-specific solution, especially on the server-side. It's easy enough to build, with a Rails action returning the status of the job in JSON, then use setTimeout and jQuery.ajax() or Prototype's Ajax.PeriodicalUpdater to poll the server at regular intervals.

You don't need a big framework or Comet server to do this.

Jonathan Julian
A: 

I ended up using a PeriodicalUpdater plugin for jQuery. Here's the link:

http://www.360innovate.co.uk/blog/2009/03/periodicalupdater-for-jquery/

btelles