In my project, I have a one-to-many relation (a Client has many contacts), Now, I am listing the clients in a Drop-down menu, What i want is, To have the Selected Client's Contacts rendered dynamically as check-boxes.

Here is (the part) of my \_form.html.haml, and the jQuery part that sends the Ajax request:

```
  %h4 This meeting is made for :
  = f.input :client_id, collection:(Client.all)
  %br
  %hr     

  %h4 Assign Contacts:
  //HERE WHERE I REALLY WANT THE CHECKBOXES TO BE REDNERED DYNAMICALLY.
  = check_box_tag "contact_ids[]", c.id, @meeting.contacts.include?(c)
  = c.first_name
  %br

  :javascript
    $(document).ready(function (){
      $('#meeting_client_id').change(function(){
      var state = $('#meeting_client_id :selected').val();
      if(state !== "")
      {
        $.getJSON('/clients/client_contacts/' + state, function(data){
        console.log(data);
        })
      }
     return false;
     })
   });

```

and here is my Clients\_controller action, that handles the request:

```
def client_contacts
  client = (params[:id])
  cou = Contact.where(client_id: client)
  @msg = { "success" => "true", "message" => "hello", "count" => cou}
  respond_to do |format|
    format.html
    format.json { render json: @msg }
  end
end

```

Now, in the console, I can see that the request is returning the count, and objects.

and hence I am really new to JS/jQuery , and fairly new to Rails, I really don't know how to take it from here.

Any tips/Articles/links/Helps or advice, is really appreciated.