我想删除多个复选框
成功删除了数据..但无法在列表中删除 我必须刷新两次才能删除数据..
这是代码
// link for click
<a href="" id="delete" class="btn btn-danger btn-flat btn-xs" onclick="delete();">Delete</a>
//checkbox
<input type="checkbox" name="id" class="data-check" id="am" value="<?php echo $row->MenuId;?>">
//function to call
function delete()
{
var list_id = [];
$(".data-check:checked").each(function() {
list_id.push(this.value);
});
if(list_id.length > 0)
{
if(confirm('Are you sure delete this '+list_id.length+' data?'))
{
$.ajax({
type: "POST",
data: {id:list_id},
url: "<?php echo site_url('General_setting/delete_multiple')?>",
dataType: "JSON",
success: function(data)
{
if(data){
window.location.href = '<?php echo site_url('General_setting'); ?>';
}
}
});
//return false;
}
}
else
{
alert('no data selected');
}
}
//controller
function delete_multiple() {
$this->load->model('Menu_model');
$data=$this->Menu_model->remove_menu();
if($data){
return true;
}
}
//// model
function remove_menu() {
$delete = $this->input->post('id');
for ($i=0; $i < count($delete) ; $i++) {
$this->db->where('MenuId', $delete[$i]);
$this->db->delete('Menu');
}
return false;
}
我不知道要回到成功还是失败 我想我有一个错误..但我不知道...你能告诉我错误在哪里.. 谢谢..