# Ajax question, not so basic I guess

**URL:** <https://www.ruby-forum.com/t/ajax-question-not-so-basic-i-guess/57063>\
**Category:** Rails\
**Created:** [April 6, 2006, 10:07pm UTC](https://www.ruby-forum.com/t/ajax-question-not-so-basic-i-guess/57063 "2006-04-06T22:07:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@daniel](https://www.ruby-forum.com/u/daniel)\
**Post date:** [April 6, 2006, 10:07pm UTC](https://www.ruby-forum.com/t/ajax-question-not-so-basic-i-guess/57063/1 "2006-04-06T22:07:12Z")

</div>

Hey

Is there a ajax method that triggers when the page is fully loaded?

I want to be able to specify which div to update, something like this:

\<%= on\_page\_loaded(  
:update =\> “generatedimage”,  
:url =\> { :action =\> :generateimage })  
%\>

What I’m trying to do is load a page with a animated gif image saying  
“custom graphics is being generated…”. When this page has finished  
loading, I want to call a remote method that generates a custom image  
and returns it, replacing the first image. The generation of the custom  
image takes a few seconds, thats why I want to display the first  
animated gif.  
(I want the replacement of the image to be done using ajax)

Can this be done?

Thank you guys for this awesome forum 🙂

//Daniel

---

<div class="post-metadata">

**Author:** ![daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@daniel](https://www.ruby-forum.com/u/daniel)\
**Post date:** [April 7, 2006, 1:17am UTC](https://www.ruby-forum.com/t/ajax-question-not-so-basic-i-guess/57063/2 "2006-04-07T01:17:04Z")

</div>

Daniel \<big@…\> writes:

> Is there a ajax method that triggers when the page is fully loaded?
> 
> I want to be able to specify which div to update, something like this:
> 
> \<%= on\_page\_loaded(  
> :update =\> “generatedimage”,  
> :url =\> { :action =\> :generateimage })  
> %\>

…

> (I want the replacement of the image to be done using ajax)

I guess a call to window.onload from javascript may solve your problem.

---

<div class="post-metadata">

**Author:** ![daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@daniel](https://www.ruby-forum.com/u/daniel)\
**Post date:** [April 7, 2006, 11:47am UTC](https://www.ruby-forum.com/t/ajax-question-not-so-basic-i-guess/57063/3 "2006-04-07T11:47:27Z")

</div>

=?utf-8?b?U8OpYmFzdGllbg==?= Grosjean wrote:

> Daniel \<big@…\> writes:
> 
> > Is there a ajax method that triggers when the page is fully loaded?
> > 
> > I want to be able to specify which div to update, something like this:
> > 
> > \<%= on\_page\_loaded(  
> > :update =\> “generatedimage”,  
> > :url =\> { :action =\> :generateimage })  
> > %\>
> 
> …
> 
> > (I want the replacement of the image to be done using ajax)
> 
> I guess a call to window.onload from javascript may solve your problem.

Is it really possible to call a remote method from a javascript?  
Can anybody point me in the right direction?

This cant be that hard… how do you usually solve these kind of  
problems?

//Daniel

---

<div class="post-metadata">

**Author:** ![daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@daniel](https://www.ruby-forum.com/u/daniel)\
**Post date:** [April 7, 2006, 12:15pm UTC](https://www.ruby-forum.com/t/ajax-question-not-so-basic-i-guess/57063/4 "2006-04-07T12:15:53Z")

</div>

Daniel wrote:

> =?utf-8?b?U8OpYmFzdGllbg==?= Grosjean wrote:
> 
> > I guess a call to window.onload from javascript may solve your problem.
> 
> Is it really possible to call a remote method from a javascript?  
> That would be the point 🙂

> This cant be that hard… how do you usually solve these kind of  
> problems?  
> window.onload=function(){  
> \<%= remote\_function(:update =\> ‘generatedimage’,  
> :url =\> {:action =\> ‘generateimage’}) %\>;  
> };

Something like that, anyway…

---

<div class="post-metadata">

**Author:** ![daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@daniel](https://www.ruby-forum.com/u/daniel)\
**Post date:** [April 7, 2006, 12:13pm UTC](https://www.ruby-forum.com/t/ajax-question-not-so-basic-i-guess/57063/5 "2006-04-07T12:13:06Z")

</div>

Ok, i take it ajax cant do the magic for me…

I think I’ll go with a pure javascript solution like this

> **[Siter](http://www.siter.com.au)**
>
> Web softwaree engineering

//Daniel
