I am using jquery datables for showing some stocks. By default all stock are showing but when I type some text in search box nothing happens, I have also check console there is no error, Please help me. Here is some code:
stock.js
$('#view-stock').DataTable({
serverSide:true,
searchable:true,
ajax:{
url:base_url+"stock/get_stock",
}..and so on
stock_controller:
public function get_stock(){
$stock['data']=$this->Stock_model->get_stock();
if(isset($_GET['search[value]'])){
$stock['data']=$this->Stock_model->get_stock($_GET['search[value]']);
}
$stock=json_encode($stock);
print_r($stock);
}
stock model:
public function get_stock($search=null){
$this->db->order_by('id','desc');
if($search!=null){
$this->db->like('p_name', $search);
$stock=$this->db->get('stockdetail');
}else{
$stock=$this->db->get('stockdetail');
}
if($stock){
return $stock->result_array();
}
return false;
}
Please help.
ignited datatables