我有工作的 codeigniter 控制器并查看成功删除记录的视图。我想用ajax - jquery来做,以避免重新加载页面,果然我需要提示用户,如果他确定要删除记录。
任何代码片段都将不胜感激,因为我不知道从哪里开始:
这是来自控制器的代码:
public function deleteUser()
{
$this->load->model('backOfficeUsersModel');
$deleteWhat = array(
'dpage' => $this->input->post('dpage'),
'rid' => $this->input->post('rid')
);
$this->backOfficeUsersModel->delete($deleteWhat['rid']);
redirect($deleteWhat['dpage']);
} // end of function deleteUser
这是我现在的观点:(为简单起见,仅提供 php 代码)
foreach ($users as $key => $user) {
echo form_open('backOfficeUsers/deleteUser');
echo form_hidden('dpage', 'backOfficeUsers/displayAllUsers');
echo form_hidden('rid', $user['userid']);
echo "<tr>";
echo "<td>";
$data = array(
'name' => 'row_sel',
'id' => $user['userid'],
'value' => $user['userid'],
'class' => 'select_row'
);
echo form_checkbox($data);
//echo "<input type='checkbox' class='select_row' name='row_sel'>";
echo "</td>";
echo "<td>" . $user['userid'] . "</td>";
echo "<td>" . $user['firstname'] . " " . $user['lastname'] . "</td> ";
echo "<td>" . $user['username'] . "</td> ";
echo "<td><a href=mailto:" . $user['email'] . ">" . $user['email'] . "</td> ";
echo "<td style='text-align: center;'>";
echo anchor("backOfficeUsers/displayEditUserForm/$user[userid]/", "<i class=splashy-pencil></i>", "class=ext_disabled");
echo "</td>";
echo"<td style='text-align: center;'>";
$confirm = "class='splashy-remove' style='border:none; width:16px; height:16px;'";
echo form_submit('submit', '', $confirm);
echo"</td></tr>";
echo form_close();
}
任何帮助(代码片段或某些示例的链接)将不胜感激
问候,佐兰