How to execute remote action once as the page loads?

Hello

One of my application pages needs to grab data from two different XMLRPC
endpoints – it’s kind of expensive sometimes. So I decided to load
that information using two separate ajax requests as the page loads.

In the view, it looks like this:

<%= image_tag "spinner.gif "%> <%= javascript_tag "var jira_loaded = false"%> <%= periodically_call_remote ( :update=> "jira_information", :frequency=>0, :url=>{:controller=>:person, :action=>:fetch_ajax_jira, :id=>@person}, :condition => "jira_loaded == false", :before => "jira_loaded = true") %>

While this works, it bugs me because I know that in the background
Safari is constantly checking the jira_loaded condition. What I would
really like to do is to execute the request just once as the page loads.
I thought about writing some javascript to do this, registering an
onLoad event, and then pulling in the data myself, but I really don’t
want to do that if there is a railsy way to do it instead.

I looked for a call_remote tag, or something related to it that would
serve this purpose, to no avail.

Thanks for any help!

On Oct 28, 8:24 am, Collin V. [email protected]
wrote:

Safari is *constantly* checking the jira_loaded condition. What I would Posted viahttp://www.ruby-forum.com/.

Did you ever find a solution for this? I have the same problem: I
need something like a “call_remote” function.

I’ve put:

render :update do |page|
page.call ‘scroll’, 0, 0
page.replace_html :campaign_errors, “ERRORS TEST”
end

into an action executed in response to a GET request and got back the
expected text/html response:

try {
scroll(0, 0);
Element.update(“campaign_errors”, “ERRORS TEST” );
} catch (e) { alert(‘RJS error:\n\n’ + e.toString()); alert(‘scroll(0,
0);\nElement.update("campaign_errors", "ERRORS TEST"");’); throw
e }

displayed, as expected, as text in the browser.

The question seems to boil down to how to call render :update in a xhr
request that returns text/javascript for execution by the browser?

Any ideas about this?