Topic: observe_form function -> submit form on page load

I have a form that is submitted by using Ajax if a value changed. The function used to submit the form is 'observe_form'.
I also want to submit the form if the page is loaded, because sometimes the form is already filled from the session. Now I do it using the prototype function 'new Ajax.Request'.

My code is now as follows:
            <%= observe_form "new_orderline", :url => 'calculators/index' %>
            <% javascript_tag do %>
                new Ajax.Request('<%= 'calculators/index' %>', {asynchronous:true, evalScripts:true, parameters:$('new_orderline').serialize() + '&authenticity_token=' + encodeURIComponent('<%= form_authenticity_token %>')})
            <% end %>

I think this code is quite ugly. Does anyone have an idea for better code? Maybe the fact that I want to submit a form on page load is quite ugly... If anyone has a better idea, please let me hear.

Re: observe_form function -> submit form on page load

jquery

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams