# How do I make an Ajax call when a page loads?

**URL:** <https://www.ruby-forum.com/t/how-do-i-make-an-ajax-call-when-a-page-loads/127312>\
**Category:** Rails\
**Created:** [January 28, 2008, 3:41am UTC](https://www.ruby-forum.com/t/how-do-i-make-an-ajax-call-when-a-page-loads/127312 "2008-01-28T03:41:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henry\_Collingridge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/db5fbb/32.png) [@Henry\_Collingridge](https://www.ruby-forum.com/u/Henry_Collingridge)\
**Post date:** [January 28, 2008, 3:41am UTC](https://www.ruby-forum.com/t/how-do-i-make-an-ajax-call-when-a-page-loads/127312/1 "2008-01-28T03:41:35Z")

</div>

Hi all,

I have a view in which periodically\_call\_remote is updating a partial  
every 5 seconds. Actually, the updating is getting done in an rjs  
which also calls effect.highlight (via visual\_effect :highlight) on  
table elements that have a certain CSS class assigned to them.  
I would like this Effect.Highlight functionality to occur on page load  
as well as every 5 seconds, so I want to make an extra call to the  
same action that is currently getting called by the  
periodically\_call\_remote statement.

What is the best way to make an Ajax call as soon as the page has  
loaded?

Thanks in advance!

Henry

---

<div class="post-metadata">

**Author:** ![Henry\_Collingridge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/db5fbb/32.png) [@Henry\_Collingridge](https://www.ruby-forum.com/u/Henry_Collingridge)\
**Post date:** [January 28, 2008, 4:00am UTC](https://www.ruby-forum.com/t/how-do-i-make-an-ajax-call-when-a-page-loads/127312/2 "2008-01-28T04:00:56Z")

</div>

Have never done it, but I’m guessing that you could do:

On Jan 27, 2008 9:31 PM, Henry Collingridge
