title: Improving a 'remote_function' using "advanced" AJAX
body: <p>I am using Ruby on Rails 3 and I am trying to improve an AJAX request in a view file using the <code>remote_function</code> method. The following code will display the text <code>Fire AJAX</code> when the mouse pointer is over the <code>&lt;div id="test_id_div"&gt;...&lt;/div&gt;</code> and will call an action controller method on clicking on the <code>Fire AJAX</code>. </p>
  
  <p>In the view file I have:</p>
  
  <pre><code>&lt;div id="test_id_div"&gt;
    &lt;span id="test_id_span" %&gt; style="display: none"&gt;
      &lt;%= link_to_function 'Fire AJAX', remote_function(:url =&gt; {:action =&gt; :action_method_name, :controller =&gt; 'controller_name'}) %&gt;
    &lt;/span&gt;
  
    &lt;%=
      update_page_tag do |page|
        page.event.observe("test_id_div", 'mouseover') do |element|
          element[("test_id_span").to_sym].show
        end
        page.event.observe("test_id_div", 'mouseout') do |element|
          element[("test_id_span").to_sym].hide
        end
      end
    %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The above code works, however I would like to improve that in some "better" way (example: writing less code, ...). <strong>How could I do that?</strong></p>
  
  <hr>
  
  <p><em>P.S.</em>: In my case the <code>Fire AJAX</code> will call an action controller method that update a record in the database, so I would like to know what I should\must know about security matter too.</p>