title: Jquery Ajax Calls With CodeIgniter
body: <p>I am trying to set up a way for two tables on my page to updated automatically or if correct me if I am wrong "Asynchronously". I need second to second updates as well. I am also using CodeIgnighter MVC framework, and as for my tables I am using DataTables. My Jquery goes as follows : </p>
  
  <pre><code>&lt;script&gt;
          function updatewaiting(){
          $('.display').load('https://www.finaidtest.com/index.php/studentqueue_controller/data');
          }
          setInterval( "updatewaiting()", 1000 );
  
      &lt;/script&gt;
  </code></pre>
  
  <p>My tables are as follows : </p>
  
  <pre><code>&lt;table id='waiting' class='display'&gt;
          &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;ID&lt;/th&gt;
              &lt;th&gt;A Number&lt;/th&gt;
              &lt;th&gt;First Name&lt;/th&gt;
              &lt;th&gt;Last Name&lt;/th&gt;
              &lt;th&gt;Time Waiting&lt;/th&gt;
              &lt;th&gt;Reason for visit&lt;/th&gt;
              &lt;th&gt;Comments&lt;/th&gt;
              &lt;th&gt;Aid Year&lt;/th&gt;
              &lt;th&gt;Staff Comments&lt;/th&gt;
              &lt;th&gt;Options&lt;/th&gt;
          &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
  
          &lt;?php
          $options = array("" =&gt; "", 'start' =&gt; 'Start Session', 'stop' =&gt; 'Student Not Present', 'abandon' =&gt; 'End Session',);
          foreach ($waiting as $row) {
              ?&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row['id'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo anchor('studentqueue_controller/history/' . urlencode($row['anum']) . '', htmlspecialchars($row['anum'], ENT_QUOTES, 'UTF-8'), 'target="_blank"'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row['first'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row['last'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row['SECOND'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row['reason'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row['studentcomments'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row['aidyear'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row['counselorcomments'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;
                  &lt;?php echo form_open('studentqueue_controller/counselorscreen/' . urlencode($row['id']) . ''); ?&gt;
                  &lt;?php echo form_dropdown('options', $options, ""); ?&gt;
                  &lt;?php echo form_submit('submit', 'Submit'); ?&gt;
                  &lt;?php echo form_close(); ?&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;?php }
          ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
  
  &lt;table id='beingseen' class='display'&gt;
          &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;ID&lt;/th&gt;
              &lt;th&gt;A Number&lt;/th&gt;
              &lt;th&gt;First Name&lt;/th&gt;
              &lt;th&gt;Last Name&lt;/th&gt;
              &lt;th&gt;Sign In Time&lt;/th&gt;
              &lt;th&gt;Staff Member&lt;/th&gt;
              &lt;th&gt;Start Time&lt;/th&gt;
              &lt;th&gt;Options&lt;/th&gt;
          &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
          &lt;?php $options1 = array("" =&gt; "", 'continue' =&gt; 'Continue Session', 'terminate' =&gt; 'Terminate Session',);
          foreach ($beingseen as $row1) {
              ?&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row1['id'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row1['anum'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row1['first'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row1['last'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row1['signintime'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row1['fname'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo htmlspecialchars($row1['starttime'], ENT_QUOTES, 'UTF-8'); ?&gt;&lt;/td&gt;
                  &lt;td&gt;
                  &lt;?php echo form_open('studentqueue_controller/counselorscreen/' . urlencode($row1['id']) . ''); ?&gt;
                  &lt;?php echo form_dropdown('options', $options1, ""); ?&gt;
                  &lt;?php echo form_submit('submit', 'Submit'); ?&gt;
      &lt;?php echo form_close(); ?&gt;
                  &lt;/td&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
  &lt;?php } ?&gt;
  
  
          &lt;/tbody&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>The Jquery function is calling on my data() method in my controller and all that does is query the database  :</p>
  
  <pre><code>function data(){
      $this-&gt;load-&gt;model('queue_model');
  
      $data['waiting'] = $this-&gt;queue_model-&gt;waiting();
      $data['beingseen'] = $this-&gt;queue_model-&gt;beingseen();
      }
  </code></pre>
  
  <p>I am quite confused as to why when I look into my network tab I see the ajax calls, but I do not see a response in the network tab. </p>
  
  <p>Just an up date : </p>
  
  <pre><code>Array ( [waiting] =&gt; Array ( [0] =&gt; Array ( [id] =&gt; 176 [0] =&gt; 176 [anum] =&gt; A00163047 [1] =&gt; A00163047 [first] =&gt; rix [2] =&gt; rix [last] =&gt; aja [3] =&gt; aja [SECOND] =&gt; 62:47:39 [4] =&gt; 62:47:39 [reason] =&gt; Award Status [5] =&gt; Award Status [studentcomments] =&gt; [6] =&gt; [aidyear] =&gt; 13-14 [7] =&gt; 13-14 [counselorcomments] =&gt; [8] =&gt; ) [1] =&gt; Array ( [id] =&gt; 179 [0] =&gt; 179 [anum] =&gt; A00163047 [1] =&gt; A00163047 [first] =&gt; rix [2] =&gt; rix [last] =&gt; aja [3] =&gt; aja [SECOND] =&gt; 00:22:29 [4] =&gt; 00:22:29 [reason] =&gt; Award Status [5] =&gt; Award Status [studentcomments] =&gt; [6] =&gt; [aidyear] =&gt; 13-14 [7] =&gt; 13-14 [counselorcomments] =&gt; [8] =&gt; ) [2] =&gt; Array ( [id] =&gt; 178 [0] =&gt; 178 [anum] =&gt; A12345678 [1] =&gt; A12345678 [first] =&gt; ririri [2] =&gt; ririri [last] =&gt; ririir [3] =&gt; ririir [SECOND] =&gt; 00:24:21 [4] =&gt; 00:24:21 [reason] =&gt; Award Status [5] =&gt; Award Status [studentcomments] =&gt; [6] =&gt; [aidyear] =&gt; 13-14 [7] =&gt; 13-14 [counselorcomments] =&gt; [8] =&gt; ) [3] =&gt; Array ( [id] =&gt; 177 [0] =&gt; 177 [anum] =&gt; A99999999 [1] =&gt; A99999999 [first] =&gt; rux [2] =&gt; rux [last] =&gt; ajaj [3] =&gt; ajaj [SECOND] =&gt; 00:29:20 [4] =&gt; 00:29:20 [reason] =&gt; Award Status [5] =&gt; Award Status [studentcomments] =&gt; [6] =&gt; [aidyear] =&gt; 13-14 [7] =&gt; 13-14 [counselorcomments] =&gt; [8] =&gt; ) ) [beingseen] =&gt; )
  </code></pre>
  
  <p>My data function in fact is returning data to the controller. I just did a print_r on my data. however that array of returned data is being placed into the table itself, </p>