我使用ajax将输入Checkbox的值发送给我的控制器。 我从我的数据库中获取数据。
但是,视图方面我只在DEBUG模式中看到结果
我认为我的问题是我的TABLE不会重新加载。
有人可以伸出援手,为什么我的观点中没有结果,只有在debuG模式下
CHECKBOX
Input = "check" type = "checkbox" name = "_ id []" id = "checkbox" checked value = "1">
Input = "check" type = "checkbox" name = "_ id []" id = "checkbox" checked value = "2">
CONTROLLER
Public function index ()
{
If ($ this-> input-> post ('c_id')) {
$ Get_id = $ this-> input-> post ('c_id');
$ Groupby_id = $ this-> model-> group_list ($ get_id);
}
$ Data ['groups'] = $ groupby_id;
}
}
MODEL
Public function gr_list ($ cp_id)
{
Return $ this-> db-> select ("*")
-> where_in ("cp_id", $ company_id)
-> get ("grs");
}
我的观看表
<Table class = "table-striped">
<Thead>
<Tr>
<Th> Groups </th>
<Th> This Wek </th>
<Th>% Chg vs LY </th>
</Tr>
</Thead>
<Tbody>
<? Php foreach ($ groups-> result () as $ gp):?>
<Tr>
<Td> <a href="#"> <? Php echo $ gp-> group_name?> </a> </td>
<Td> <? Php echo $ gp-> amount?></td>
<Td> <a href="#"> <span class = "glyphicon glyphicon-arrow-up"> </a> </ span> <? Php echo $ gp-> compvalue?
</ Tr>
<? Php endforeach; ?>
</Tbody>
</Table>
AJAX
$('input[type=checkbox]').on('change', function() {
if($(this).is(':checked')){
var values = [];
$.each($('input:checked'),function(index,input){
values.push(input.value);
});
$.ajax({
type: "POST",
async: true,
cache: false,
url: "<?php echo site_url('index') ?>",
data: { c_id:values }
}).done(function(data) {
console.log(data);
})
e.preventDefault();
}
});
$("#checkAll").click(function () {
$(".check").prop('checked', $(this).prop('checked'));
});