title: Rails ajax background requests
body: <p>I have a remote_form which works 100%</p>
  
  <p>When a user clicks submit, it goes out grabs so data from the db or data scraped from another website, and updates the page seamlessly... </p>
  
  <p>The problem I'm having now, is that I'd like to do the same thing, but do it without having the user click the submit button with an onload event.  I think I'm going about it the wrong way:</p>
  
  <p>Technically this works... it does get the right data, but instead of doing exactly what the remote_form_tag does it returns the data raw. No RJS replace_html. </p>
  
  <p>Is there a way to skip the form_for altogether and just execute the controller action directly when the page loads?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(window).load(function() {
          // executes when HTML-Document is loaded and DOM is ready
          // jQuery.facebox('Big loading! &lt;img alt=\"Loading\" src=\"/images/loaders/loading.gif\" /&gt;');
          //$("#update_form").submit();
          $("#update_form").submit(function () { return false; });
  
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>The form for</p>
  
  <pre><code>#html.erb
  &lt;%  form_remote_tag :url =&gt; { :action =&gt; "update_availables", :id =&gt; params[:id] },
      :loading =&gt; "jQuery.facebox('Big loading! &lt;img alt=\"Loading\" src=\"/images/loaders/loading.gif\" /&gt;');",
      :html =&gt; { :method =&gt; "get" },
      :method =&gt; "get",
      :html =&gt; { :id =&gt; 'update_form' } do %&gt;
  </code></pre>
  
  <p>The controller</p>
  
  <pre><code>  def update_availables
      @do_it = Available.get_new_availables :id =&gt; params[:id], :date =&gt; user_cart.getDate.to_s
      get_availables
  
      respond_to do |format|
        format.html
        format.js
      end
    end
  </code></pre>
  
  <p>RJS</p>
  
  <pre><code>page.replace_html :rooms, :partial =&gt; "available"
  page &lt;&lt; "jQuery.facebox.close();"
  </code></pre>