# Trying to understand periodically\_call\_remote() javascript prototype helper

**URL:** <https://www.ruby-forum.com/t/trying-to-understand-periodically-call-remote-javascript-prototype-helper/172909>\
**Category:** Ruby\
**Created:** [July 29, 2009, 10:03pm UTC](https://www.ruby-forum.com/t/trying-to-understand-periodically-call-remote-javascript-prototype-helper/172909 "2009-07-29T22:03:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![explainer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbce88/32.png) [@explainer](https://www.ruby-forum.com/u/explainer)\
**Post date:** [July 29, 2009, 10:03pm UTC](https://www.ruby-forum.com/t/trying-to-understand-periodically-call-remote-javascript-prototype-helper/172909/1 "2009-07-29T22:03:06Z")

</div>

I have the following code snippet on the documents#index view page of  
my rails app.

\<%= periodically\_call\_remote(  
:url =\> {:controller =\> ‘documents’, :action =\> ‘index’},  
:update =\> ‘documents’,  
:method =\> ‘get’ )  
%\>

The page shows a table of document records. Since these records can  
be updated asynchronously by a message broker feed, I want the above  
code to activate every 10 seconds (the default) and refresh the page.

Now, the page has a sidebar and when the time ticks the first time, I  
get a complete copy of the entire page, including the sidebar,  
inserted into the main table section of the page. I think the problem  
is in specifying the :update =\> ‘documents’ div, but I just don’t get  
how to scope the region to be updated.

I can supply more info, such as the layout page and so forth, just ask.

---

<div class="post-metadata">

**Author:** ![explainer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bbce88/32.png) [@explainer](https://www.ruby-forum.com/u/explainer)\
**Post date:** [July 30, 2009, 4:36pm UTC](https://www.ruby-forum.com/t/trying-to-understand-periodically-call-remote-javascript-prototype-helper/172909/2 "2009-07-30T16:36:49Z")

</div>

explainer wrote:

> I have the following code snippet on the documents#index view page of  
> my rails app.
> 
> \<%= periodically\_call\_remote(  
> :url =\> {:controller =\> ‘documents’, :action =\> ‘index’},  
> :update =\> ‘documents’,  
> :method =\> ‘get’ )  
> %\>
> 
> The page shows a table of document records. Since these records can  
> be updated asynchronously by a message broker feed, I want the above  
> code to activate every 10 seconds (the default) and refresh the page.
> 
> Now, the page has a sidebar and when the time ticks the first time, I  
> get a complete copy of the entire page, including the sidebar,  
> inserted into the main table section of the page.

Please ask Rails questions on the Rails mailing list in future. This  
mailing list is for Ruby (the programming language) not Rails (the web  
framework).

But for a quick answer, I suspect that you need to check in your  
controller for an AJAX request and return only the part of the page you  
want inserted, not the whole page.

e.g.

if request.xhr?  
render :partial=\>“something”, :object=\>something  
else  
… do normal HTML rendering  
end
