数据表请求行0的未知参数'0' [英] Datatables requested unknown parameter '0' for row 0

查看:176
本文介绍了数据表请求行0的未知参数'0'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从数据库中的客户端表中获取数据时,我遇到这个问题

I've got this problem when i try to get data from clients table in the database

DataTables警告:table id = example - 请求的未知参数对于第0行,0。有关此错误的更多信息,请参见 http://datatables.net/tn/4

DataTables warning: table id=example - Requested unknown parameter '0' for row 0. For more information about this error, please see http://datatables.net/tn/4

这是我的Codeigniter控制器

This is my Controller in Codeigniter

class Clients extends CI_Controller  {

    function header()
    {
        $data['hms'] = $this->config->item('page_title');
        $this->load->view('header3',$data);
    }

    public function index()
    {

        //$this->datatables->select('*');
        //$this->datatables->from('bookitguests');
        //$data['clients'] = $this->datatables->generate();
        $data = "";
        $this->header();
        $this->load->view('all_guests',$data);
    }

    public function TableClients()
    {
        $this->datatables->select('name, surname, email')->from('bookitguests');
        echo $this->datatables->generate();
    }

}

这是我在Codeigniter ps,im不添加头文件,它太长)

This is my view in Codeigniter (ps, im not adding the header file, its too long)

<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.1/css/jquery.dataTables.css">
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.1/js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript" charset="utf-8">
    $(document).ready(function() {
        $('#example').DataTable( {
            "bProcessing": false,
            "bServerSide": false,
            "sAjaxSource": "<?php base_url(); ?>clients/TableClients",
            "sServerMethod": "POST"
        } );
    } );
</script>

<div id="container">
    <h1>All Clients</h1>

    <div id="body">
        <table id="example" class="display">
            <thead>
            <tr>
                <th>Name</th>
                <th>Surname</th>
                <th>Email</th>
            </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds</p>
</div>
</body>
</html>


推荐答案

您只需指定列

"columns": [
                { "data": "id" },
                { "data": "name" }
              ]

这篇关于数据表请求行0的未知参数'0'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆