当我尝试通过 ajax jquery 成功发送数据时,我得到了整个页面 html 。其他功能在这里工作是我的代码。
<form id ="" action ="" method ="POST">
<?php
$counter = 0 ;
foreach ($all_users as $user) {
?>
<tr class="">
<td><?php echo $user->user_name; ?></td>
<td><?php echo $user->level ;?></td>
<td>asd</td>
<td><a class="edit" href="javascript:;">Edit</a></td>
<td><a class="delete" onclick ="delete_user($(this),<?php echo $user->id;?>)">Delete</a></td>
</tr>
<?php
$counter ++;
}
?>
</form>
javascript
function delete_user(row_id,user_id)
{
if (confirm('Do you really want to delete')) {
row_id.closest('tr').remove();
$.ajax({
type: "POST",
url: "delete_user/",
data: { "user_id":user_id },
success: function(msg) {
//alert("Name = " + msg);
}
});
}
else {
// Do nothing!
}
}
在 CI
function delete_user()
{
$user_id = $this->input->post('user_id');
$this->load->model("m_user");
$this->m_user->delete_user($user_id);
echo $result;
echo $user_id;
}
我可以看到它发送了帖子并且也发送了数据,但是我没有得到回复,我得到了整个 html 页面代码。