我有一个控制器,它在模型中发送两个函数的结果,如下所示:
$data['waiting'] = $this -> queue_model -> waiting();
$data['beingseen'] = $this -> queue_model -> beingseen();
$this -> load -> view('studentqueue/studentqueue', $data);
在我看来,我有一个显示数据的 jquery 网格。当有一条新数据插入数据库时,我的老板需要该表自动更新日期,在这种情况下会影响查询结果。
我正在尝试遵循本教程
但我对数据到底是什么感到困惑。
在我发送 $data 的控制器中,它如何与 ajax 调用中的数据集成?
我在同一页面上有两个数据网格,它们都需要异步更新。
因此,只是为了绝对清楚问题是什么:
如何将我传递给视图的控制器数据集成到 ajax 调用中,以便更新我的表。-- 我有两个表,它们都有相同的类 id,但如果你愿意,可以使用不同的表 id。
我的表格的 html 是:
<?php echo anchor('staff_controller/index', 'Return');?>
<p class='error'>
<font color="#ff0000">
<?php echo $this->session->flashdata('reports');?>
</font>
</p>
<h3>Students Waiting</h3>
<table id='waiting' class='display'>
<thead>
<tr>
<th>ID</th>
<th>A Number</th>
<th>First Name</th>
<th>Last Name</th>
<th>Time Waiting</th>
<th>Reason for visit</th>
<th>Comments</th>
<th>Aid Year</th>
<th>Staff Comments</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<?php $options = array("" => "", 'start' => 'Start Session', 'stop' => 'Student Not Present', 'abandon' => 'End Session', );
foreach ($waiting as $row)
{
?>
<tr>
<td><?php echo htmlspecialchars($row['id'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo anchor('studentqueue_controller/history/'.urlencode($row['anum']). '', htmlspecialchars($row['anum'], ENT_QUOTES, 'UTF-8'), 'target="_blank"'); ?></td>
<td><?php echo htmlspecialchars($row['first'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row['last'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row['SECOND'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row['reason'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row['studentcomments'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row['aidyear'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row['counselorcomments'], ENT_QUOTES, 'UTF-8'); ?></td>
<td>
<?php echo form_open('studentqueue_controller/counselorscreen/' .urlencode($row['id']). ''); ?>
<?php echo form_dropdown('options', $options, ""); ?>
<?php echo form_submit('submit', 'Submit'); ?>
<?php echo form_close(); ?>
</td>
</tr>
<?php
} ?>
</tbody>
</table>
被看见的学生
<table id='beingseen' class='display'>
<thead>
<tr>
<th>ID</th>
<th>A Number</th>
<th>First Name</th>
<th>Last Name</th>
<th>Sign In Time</th>
<th>Staff Member</th>
<th>Start Time</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<?php $options1 = array("" => "", 'continue' => 'Continue Session', 'terminate' => 'Terminate Session', );
foreach ($beingseen as $row1) { ?>
<tr>
<td><?php echo htmlspecialchars($row1['id'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row1['anum'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row1['first'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row1['last'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row1['signintime'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row1['fname'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlspecialchars($row1['starttime'], ENT_QUOTES, 'UTF-8'); ?></td>
<td>
<?php echo form_open('studentqueue_controller/counselorscreen/' .urlencode($row1['id']). ''); ?>
<?php echo form_dropdown('options', $options1, ""); ?>
<?php echo form_submit('submit', 'Submit'); ?>
<?php echo form_close(); ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>