严重性:通知消息:未定义的索引:draw(数据表codeigniter)

时间:2018-10-19 21:37:26

标签: javascript ajax codeigniter datatables codeigniter-3

我试图在codeigniter中将数据库中的数据显示到数据表中,服务器正常工作并返回200,但问题是返回

  

严重性:通知

     

消息:未定义索引:绘制

我已经阅读了该主题,但是没有解决方案,所以这就是我要问的问题

Notice: Undefined index: draw using Datatables.net server-side

这是我的控制器

function fetch_okastable(){  
  $id_p = $this->session->userdata("id_p"); 
  $load_data = $this->Pru_model->make_okas_tables($id_p);  
  $data = array();  
  $no = 1;
  foreach($load_data as $row){  
    $sub_array[] = $no++;  
    $sub_array[] = $row->name;
    $sub_array[] = $row->place;
    $sub_array[] = $row->category;
    $sub_array[] = '<button type="button" name="update" id="'.$row->id.'" class="btn btn-warning btn-xs">Update</button>';
    $sub_array[] = '<button type="button" name="delete" id="'.$row->id.'" class="btn btn-danger btn-xs delete"> <i class="fa fa-trash"></i></button>';
    $data[] = $sub_array;  
  }  
  $output = array(  
    "draw"                    =>     intval($_POST["draw"]),  
    "recordsTotal"            =>      $this->Pru_model->get_all_data($id_p),  
    "recordsFiltered"         =>     $this->Pru_model->get_filtered_org($id_p),  
    "data"                    =>     $data  
  );  
  echo json_encode($output);}  

这是我的模式详细信息

var $select_column = array("id","id_p","name","place","category","img");
var $order_column =  array(null,"id_p","name","place","category",null); 
function make_query_okas($id_p){  
       $this->db->select($this->select_column);  
       $this->db->from("okas_table"); 
       $this->db->where("id_p",$id_p); 
       if(isset($_POST["search"]["value"]))  
       {  
            $this->db->like("id",$_POST["search"]["value"]);
            $this->db->or_like("name", $_POST["search"]["value"]);  
            $this->db->or_like("place", $_POST["search"]["value"]);
            $this->db->or_like("category", $_POST["search"]["value"]);  
       }  
       if(isset($_POST["order"]))  
       {  
            $this->db->order_by($this->order_column[$_POST['order']['0']['column']], $_POST['order']['0']['dir']);  
       }  
       else  
       {  
            $this->db->order_by('id', 'DESC');  
       }
}
function make_okas_tables($id_p){ 
  $id_p = $this->session->userdata("id_p");  
  $this->make_query_okas($id_p);  
  if(isset($_POST["length"]) && $_POST["length"] != -1)  
  {  
    $this->db->limit($_POST['length'], $_POST['start']);  
  }  
       $query = $this->db->get();  
       return $query->result();  
} 
function get_filtered_okas($id_p){  
       $this->make_query_okas($id_p);  
       $query = $this->db->where('id_p', $id_p, FALSE)
                          ->get();  
       return $query->num_rows();  
}
function get_all_data($id_p){  
       $this->db->where('id_p', $id_p, FALSE)
                ->from("okas_table");  
       return $this->db->count_all_results();  
} 

最后一个...这是我的观点

<div class="card-body">
                <div class="table-responsive">                       
                  <table id="orgAkt_data" class="table table-striped table-hover">
                    <thead>
                      <tr>
                        <th>#</th>
                        <th>Name</th>
                        <th>Place</th>
                        <th>Category</th>
                      </tr>
                    </thead>        
                  </table>
                </div>
              </div>
              <script>
                $(document).ready(function(){  
                  var dataTable = $('#okas_data').DataTable({  
                     "processing":true,  
                     "serverSide":true,  
                     "order":[],  
                     "ajax":{  
                          url:"<?php echo base_url() . 'PruCtrl/fetch_okastable'; ?>",  
                          type:"POST"  
                     },  
                     "columnDefs":[{    
                        "orderable":false,  
                      },  
                    ],  
                  });
                </script>

0 个答案:

没有答案