【发布时间】:2016-12-20 16:14:20
【问题描述】:
我正在使用 Codeigniter 2.x
我的控制器功能
function remove(){
$id = $this->input->post("id");
$res = $this->ask_model->remove($id);
if($res){
$data = array('msg' => 'Removed');
} else {
$data = array('msg' => 'Not removed');
}
echo json_encode($data);
}
注意:我写的是echo json_encode($data)。
我的模型
function remove($inpt){
$stat = array('stat' => 0);
$this->db->where('id',$inpt);
$this->db->update('uploads',$stat);
if ($this->db->affected_rows() > 0) {
return true;
} else {
return false;
}
}
AJAX
$(".prv .rmv").click(function () {
var rmval = $(this).attr('id');
$.ajax({
url: '<?php echo site_url("user-question-edit/remove"); ?>',
data: {"id": rmval},
dataType:'json',
type: "post",
success: function(data){
console.log(data.msg);
}
});
});
在执行上述操作时,我的 MySQL 表正在更新,但 console.log 显示
POST http://path/to/user-question-edit/remove/net::ERR_CONTENT_DECODEDING_FAILED
状态显示失败。
我应该怎么做才能检查响应?
更新:我错误地输入了我的模型函数remove_upload。
【问题讨论】:
标签: jquery ajax codeigniter