# Periodic update related question

**URL:** <https://www.ruby-forum.com/t/periodic-update-related-question/168726>\
**Category:** Rails\
**Created:** [May 25, 2009, 6:21am UTC](https://www.ruby-forum.com/t/periodic-update-related-question/168726 "2009-05-25T06:21:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@sudhi](https://www.ruby-forum.com/u/sudhi)\
**Post date:** [May 25, 2009, 6:21am UTC](https://www.ruby-forum.com/t/periodic-update-related-question/168726/1 "2009-05-25T06:21:26Z")

</div>

HI,

I am looking to do something like the following – “Update a text area  
with the content of a file on the server every 5 second once. This  
activity should start once the “Run” button on my page is clicked”

What is the best approach to do this? The file is a log file so no  
security concerns.

Thanks,  
Sudhindra

---

<div class="post-metadata">

**Author:** ![sudhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@sudhi](https://www.ruby-forum.com/u/sudhi)\
**Post date:** [May 25, 2009, 9:08am UTC](https://www.ruby-forum.com/t/periodic-update-related-question/168726/2 "2009-05-25T09:08:43Z")

</div>

Every 5 second once is not understandable.

If you want to click a button to update some text, then probably the  
easiest would be simply to refresh the page with a form and button  
where the target is an empty string.

Julian.

* * *

Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Twitter: [http://twitter.com/random8r](http://twitter.com/random8r)  
Learn: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)  
Latest: How to use Unix basics at [http://sensei.zenunit.com/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![sudhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@sudhi](https://www.ruby-forum.com/u/sudhi)\
**Post date:** [May 25, 2009, 9:56am UTC](https://www.ruby-forum.com/t/periodic-update-related-question/168726/3 "2009-05-25T09:56:19Z")

</div>

Julian L. wrote:

> Every 5 second once is not understandable.
> 
> If you want to click a button to update some text, then probably the  
> easiest would be simply to refresh the page with a form and button  
> where the target is an empty string.
> 
> Julian.
> 
> * * *
> 
> Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
> Twitter: [http://twitter.com/random8r](http://twitter.com/random8r)  
> Learn: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)  
> Latest: How to use Unix basics at [http://sensei.zenunit.com/](http://sensei.zenunit.com/)

Sorry it is once every 5 seconds… so after every 5 seconds I should be  
able to read file on server and show the output

Thanks,  
Sudhindra

---

<div class="post-metadata">

**Author:** ![sudhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@sudhi](https://www.ruby-forum.com/u/sudhi)\
**Post date:** [May 25, 2009, 12:39pm UTC](https://www.ruby-forum.com/t/periodic-update-related-question/168726/4 "2009-05-25T12:39:17Z")

</div>

On 25/05/2009, at 5:56 PM, Sudhi K. wrote:

> should be  
> able to read file on server and show the output

So every five seconds it should update the view?

This would call for a periodically call remote, or you could simply  
put an HTTP refresh in the head tag of the html, depending on how big  
the returned page is.

Make sure you have the javascripts included for prototype (defaults)  
on the page, and then use the api as discussed here:

[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001615](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001615)

This will call an action you specify in the call, and this should  
replace the contents (innerhtml) of an id’d html entity…

Julian.

* * *

Learn: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)  
Last updated 20-May-09 (Rails, Basic Unix)  
Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Twitter: [http://twitter.com/random8r](http://twitter.com/random8r)
