title: Bind dropdown using jQuery in ruby on rails
body: <p>I have following form in html.erb file</p>
  
  <p>users.html.erb</p>
  
  <pre><code> &lt;% form_tag (:action =&gt;:abc_action)do%&gt;
                              &lt;%= label_tag(:user,"Select User") %&gt;&lt;br/&gt;
                               &lt;%=collection_select("user",id",@result,"uid","uid",:prompt=&gt;"--Select User--")%&gt;&lt;br/&gt;
      &lt;%= collection_select("subject", "id",@res,"id", "id",:prompt=&gt;"--Select Subject--")%&gt;&lt;br/&gt;
  
     &lt;%= submit_tag 'Submit',:id =&gt; 'btn'%&gt;
                      &lt;%end %&gt;
  </code></pre>
  
  <p>I want to change content of second dropdown according to selected value of first dropdown.</p>
  
  <p>For this, I m calling jQuery method on change event of first dropdown. The controller is working properly and value returned by controller is of array type.</p>
  
  <p>My jQuery code is....  </p>
  
  <pre><code>jQuery(document).ready(function() {
  jQuery("#edetail_id").change(function() {
      jQuery.get('/requests/find_val/?emid=' + jQuery("#user_id").val(),function(data)
     {
  
            jQuery("#subject_id").html(data);
     }); 
   });
  });
  </code></pre>
  
  <p>My Controller is Users_controller.rb</p>
  
  <pre><code> def find_val
   @acc = user.find(:all, :conditions =&gt; ["uid = ?", params[:emid] ])
       @res = Array.new
                              for result in @acc
                                      @res &lt;&lt; result.ndid
                              end
  
            render :text =&gt; @res
  
   end
  </code></pre>
  
  <p>Please anyone help me.. How can i do this?</p>