Ajax question, not so basic I guess

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 :slight_smile:

//Daniel

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.

=?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

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 :slight_smile:

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…

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

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

//Daniel