Rails 3 equivalent for periodically_call_remote

后端 未结 6 1270
刺人心
刺人心 2020-11-29 04:05

Seems like periodically_call_remote is deprecated in Rails 3, any ideas how to achieve the same functionality?

6条回答
  •  粉色の甜心
    2020-11-29 04:32

    Use setInterval to periodically run a function which invokes an AJAX call. If you were doing it with jQuery, it might be something like:

    var pollBackend = function() {
      $.getJSON("/foo/bar/poll");
    }
    
    setInterval(pollBackend, 5000);
    

    This would attempt to poll the given URL for JSON data every 5 seconds.

提交回复
热议问题