Forum: Ruby on Rails Timer for AJAX calls in Rails?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
764996e8a8df625a5fea0a7a211bf37e?d=identicon&s=25 Chris Stewart (Guest)
on 2007-06-22 04:18
(Received via mailing list)
Say I want to perform an ajax action every 10 seconds.  Is there a timer
function in the built-in JavaScript libraries that will let me do this?

--
Chris Stewart
compiledmonkey@gmail.com
http://www.compiledmonkey.com
6448b40e7037dd0fda767f2370c31809?d=identicon&s=25 Chris Hulbert (chris_hulbert)
on 2007-06-22 06:44
Chris Stewart wrote:
> Say I want to perform an ajax action every 10 seconds.  Is there a timer
> function in the built-in JavaScript libraries that will let me do this?
>
> --
> Chris Stewart
> compiledmonkey@gmail.com
> http://www.compiledmonkey.com

Yes there is. Can't remember it right now, but i've used it before...
6448b40e7037dd0fda767f2370c31809?d=identicon&s=25 Chris Hulbert (chris_hulbert)
on 2007-06-22 06:45
Here it is:

periodically_call_remote(options = {})

Periodically calls the specified url (options[:url]) every
options[:frequency] seconds (default is 10). Usually used to update a
specified div (options[:update]) with the results of the remote call.
The options for specifying the target with :url and defining callbacks
is the same as link_to_remote.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-06-27 05:54
(Received via mailing list)
Chris Stewart wrote:

> Say I want to perform an ajax action every 10 seconds.  Is there a timer
> function in the built-in JavaScript libraries that will let me do this?

periodically_call_remote ?

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657/
  "Test Driven Ajax (on Rails)"
  assert_xpath, assert_javascript, & assert_ajax
E2b3bbf241a5daee3ee7696a7d4b2015?d=identicon&s=25 Vrtwo Lastname (d0t1q)
on 2007-07-06 23:59
(Received via mailing list)
How can I prevent the loading of /test/blank in this example?

<%= periodically_call_remote(:url => "/test/blank", :complete
=>'addRow("something");return false;', :frequency => 3) %>

All I want to do here is call the javascript function addRow, however
I could not figure out how to accomplish this with out
leveraging :complete

Any idea? I don't really want to call /test/blank

Thanks in advance
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-07-07 01:38
(Received via mailing list)
neutek wrote:

> How can I prevent the loading of /test/blank in this example?
>
> <%= periodically_call_remote(:url => "/test/blank", :complete
> =>'addRow("something");return false;', :frequency => 3) %>
>
> All I want to do here is call the javascript function addRow, however
> I could not figure out how to accomplish this with out
> leveraging :complete
>
> Any idea? I don't really want to call /test/blank

I suspect if you leave the :url out, and leverage :complete, your
browser
will periodically call raw JavaScript without hitting a server.

I formerly posted that you could right after I discovered it, but I have
since retired that code, so Google for the topic and my street name if
you
get stuck.

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657/
  "Test Driven Ajax (on Rails)"
  assert_xpath, assert_javascript, & assert_ajax
This topic is locked and can not be replied to.