Requested unknown parameter '0' for row 0.

Requested unknown parameter '0' for row 0.

stichcomberstichcomber Posts: 26Questions: 7Answers: 3

I am receiving the following error:

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

<table id="userlist" class="display">
                        <thead>
                            <tr>
                                    <th>id</th>
                                    <th>ip_address</th>
                                    <th>username</th>
                                    <th>password</th>
                                    <th>salt</th>
                                    <th>email</th>
                                    <th>activation_code</th>
                                    <th>forgotten_password_code</th>
                                    <th>forgotten_password_time</th>
                                    <th>remember_code</th>
                                    <th>created_on</th>
                                    <th>last_login</th>
                                    <th>active</th>
                                    <th>first_name</th>
                                    <th>last_name</th>
                                    <th>company</th>
                                    <th>phone</th>
                            </tr>
                        </thead>

                        <tfoot>
                            <tr>
                                                                        <th>id</th>
                                    <th>ip_address</th>
                                    <th>username</th>
                                    <th>password</th>
                                    <th>salt</th>
                                    <th>email</th>
                                    <th>activation_code</th>
                                    <th>forgotten_password_code</th>
                                    <th>forgotten_password_time</th>
                                    <th>remember_code</th>
                                    <th>created_on</th>
                                    <th>last_login</th>
                                    <th>active</th>
                                    <th>first_name</th>
                                    <th>last_name</th>
                                    <th>company</th>
                                    <th>phone</th>
                            </tr>
                        </tfoot>



                        <tbody>
                        </tbody>

                    </table>

Here is MY_User_Table.js

            $(document).ready(function () {
                        // var table = $('#myDataTable').DataTable();
                        var table = $('#userlist').DataTable( {
                            "ajax": "json_get_users",
                        } ); 
            });

Well, using codeigniter here but pretty generic:

public function json_get_users(){
        $this->load->model('MY_Users');
        echo json_encode($this->MY_Users->get_users());
}

And this is the data that is trying to be mapped to the table:

{"aaData":[{"id":"1","ip_address":"21xxxxxxx","username":"administrator","password":"xxxxxxxxxxxxxx","salt":"","email":"admin@admin.com","activation_code":"","forgotten_password_code":null,"forgotten_password_time":null,"remember_code":null,"created_on":"xxxxxxxx","last_login":"xxxxxx","active":"1","first_name":"Admin","last_name":"istrator","company":"ADMIN","phone":"0"}]}

Any guidance much appreciated.

Brgds
Richard

This question has an accepted answers - jump to answer

Answers

  • stichcomberstichcomber Posts: 26Questions: 7Answers: 3

    I have counted the number of fields in the db, relooked the view and all match up. Hmmm :-(

  • stichcomberstichcomber Posts: 26Questions: 7Answers: 3
    Answer ✓

    Solved it.

    Data is of this type: http://datatables.net/examples/ajax/objects.html

    Changed script as follows:

    $(document).ready(function () {
                                $('#userlist').DataTable( {
                                 "ajax": "json_get_users",
                                    "columns": [
                                        { "data": "id" },
                                        { "data": "ip_address" },
                                        { "data": "username" },
                                        { "data": "password" },
                                        { "data": "salt" },
                                        { "data": "email" },
                                        { "data": "activation_code" },
                                        { "data": "forgotten_password_code" },
                                        { "data": "forgotten_password_time" },
                                        { "data": "remember_code" },
                                        { "data": "created_on" },
                                        { "data": "last_login" },
                                        { "data": "active" },
                                        { "data": "first_name" },
                                        { "data": "last_name" },
                                        { "data": "company" },
                                        { "data": "phone" }
                                    ]
                                } ); 
                    });
    
This discussion has been closed.