title: Refresh list after save data using AJAX Codeigniter
body: <p>Hello I want to insert data into database using AJAX Codeigniter using modal box Bootstrap, I can insert my data into my table, but I found a result not what I want. When I after insert data I want to show my new data in the end of list, the action after save is close the modal then add my list (my lists are checkbox data) but my new list is retrieve entire data from my table. Could you like to solve my problem..Thanks</p>
  
  <p>Here is my controller</p>
  
  <pre><code>function list_type_placement(){
          $type_placement=$this-&gt;type-&gt;get_by('level',1);
          if ($type_placement&lt;&gt;0) {
              $row=0;
              foreach ($type_placement as $key =&gt; $value) {
                  $row++;
                  echo "
                      &lt;div class='checkbox' id='rows".$row."'&gt;
                          &lt;input id=".$value-&gt;id_type." type='checkbox' name='id_type[]'' value=".$value-&gt;id_type."&gt;
                          &lt;label for=".$value-&gt;id_type."&gt;
                              ".$value-&gt;type_name."
                          &lt;/label&gt;
                       &lt;/div&gt;
                  ";
              }
          }
          exit;
      }
  </code></pre>
  
  <p>My View </p>
  
  <pre><code>&lt;div id="placement"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And this is my ajax action</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    $(document).ready(function(){
      list_placement();
    });
    function list_placement(){
      $.ajax({
        url:"&lt;?php echo base_url() ?&gt;product/list_type_placement",
        type:'GET',
      }).done(function(response){
        $("#placement").append(response);
      });
    }
    function save(){
      $('#btnSave').text('Saving...');
      $('#btnSave').attr('disabled',true);
  
      $.ajax({
        url : "&lt;?php echo site_url('product/save_placement')?&gt;",
        type: "POST",
        data: $('#form').serialize(),
        dataType: "JSON",
        success: function(data)
        {
          if(data.status)
          {
            $('#modal-form').modal('hide');
            list_placement();                                
          }        
        }
      }).done(function(response){
            $("#placement").last().append(response);
      });
    }
  &lt;/script&gt;
  </code></pre>
  
  <p>This is my current output </p>
  
  <p><a href="https://i.stack.imgur.com/C7yd0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C7yd0.jpg" alt="enter image description here"></a></p>