开发者

Are there any Rails Plugins that use JS to poll the server for completion of a background process?

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


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.


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜