Php Codeigniter HMVC Ajax
在我的问题上我需要一些帮助。 我有一个用户列表,我想在CI-HMVC中使用ajax单击delete按钮删除用户。这是我的列表视图的代码Php Codeigniter HMVC Ajax,php,jquery,ajax,codeigniter,hmvc,Php,Jquery,Ajax,Codeigniter,Hmvc,在我的问题上我需要一些帮助。 我有一个用户列表,我想在CI-HMVC中使用ajax单击delete按钮删除用户。这是我的列表视图的代码 $(function() { $(".tip-del").click(function() { var recId = $(this).data("id"); var parent = $(this).parent(); var BASE_URL = "<?php echo base_url()?&g
$(function() {
$(".tip-del").click(function() {
var recId = $(this).data("id");
var parent = $(this).parent();
var BASE_URL = "<?php echo base_url()?>";
var r = confirm("Are you sure you want to delete this user?");
if(r == true){
$.ajax({
url : BASE_URL + 'auth/delete_user',
type: 'post',
data: {'rec_id' : recId },
success: function (response){
try{
if(response == 'true'){
parent.slideUp('slow',function(){$(this).remove();});
}
}catch(e) {
alert('Exception while request..');
}
},
error: function (xhr, text, message) {
console.log(message);
}
});
return false;
}
});
});
这是我的模型代码
public function deleteUser($id) {
if ($this->db->delete('users', array('id' => $id)) && $this->db->delete('users_groups', array('user_id' => $id))) {
return true;
}
return FALSE;
}
谁能帮我一下吗。我不明白我做错了什么。在ajax响应的预览中,我得到了如下错误:
An Error Was Encountered. The action you have requested is not allowed.
提前谢谢。我认为您的删除查询是错误的。其应如下所示(在型号代码中):
是否存在与错误相关联的行号和文件,或者是从codeigniter返回的web视图?请检查以确保您的db用户具有执行delete()的正确权限,这可能是问题所在。感谢Rahul,您解决了我的问题。非常感谢你。
An Error Was Encountered. The action you have requested is not allowed.
if ($this->db->where(array('id' => $id))->delete('users') && $this->db->where(array('user_id' => $id))->delete('users_groups')) {
return true;
}