title: How to retrieve multiple objects using AJAX in CodeIgniter?
body: <p>I am preparing an 'admin' notes table in my website. Basically, I want to do two things: </p>
  
  <ol>
  <li>Insert a new note into 'notes' table in DB using AJAX.  </li>
  <li>If the the insertion is successful, update the notes table displayed on the page using AJAX.</li>
  </ol>
  
  <p>-</p>
  
  <pre><code>$('#form_add_btn').click(function(){
  
      var form_data = {
          note: $('#note_text').val(),
          type: $('#form_type_select').val(),
      }
  
      $.ajax({
          url: "&lt;?php echo base_url();?&gt;admin/add_note",
          type: 'POST',
          data: form_data,
          success: function(msg)
          {
              $('#note_msg').html(msg); 
          }
      });
  
  return false;
  });
  </code></pre>
  
  <p>At the moment controller method add_note() adds the note via model and returns true or false, which is loaded into view and returned.</p>
  
  <pre><code>public function add_note() {
      $note = $this-&gt;input-&gt;post('note');
      $type = $this-&gt;input-&gt;post('type');
  
      $data['is_success'] = $this-&gt;model_admin-&gt;add_note($note, $type);
      $this-&gt;load-&gt;view('admin/add_note', $data);
  }
  </code></pre>
  
  <p>I would like to do another AJAX request if $data['is_success'] is true :</p>
  
  <pre><code>$.ajax({
          url: "&lt;?php echo base_url();?&gt;admin/get_notes_table",
          type: 'POST',
          success: function(table) 
          {
              $('#wrap').html(table);
          }
  });
  </code></pre>
  
  <p>How can I acomplish this ? I tried placing the second request inside and after the first,  but I still need to known if the insertion was successful.</p>
  
  <p>I'm just beginning to learn CI and AJAX in jQuery, would really appreciate your help. Thanks !</p>