Requested unknown parameter '0' for row 0

Requested unknown parameter '0' for row 0

Art_MOO_styleArt_MOO_style Posts: 4Questions: 1Answers: 0

Hi!
I get error Requested unknown parameter '0' for row 0.
Please review code:
JS

$(document).ready(function() {

    table = $('#table').dataTable({

                'destroy': true,
                'processing': true,
                'serverSide': true,
                'ajax':

                {'url': '1.php', 'type': 'POST'

                },

                "columns": [
                    { "aaData": "Name"},
                    { "aaData": "Position"},
                    { "aaData": "Office"},
                    { "aaData": "Start date"},
                    { "aaData": "Salary"}
                ]

    });
});

PHP

$output = array(
    "aaData" => array()
);

$Data = array('Name' => 'apple', 'Position' => 'Office', 'Extn' => 'catnip', 'Start date' => 'catnip','Salary' => 'catnip');
$output['aaData'][] = $Data;


header('Content-type: text/javascript');
echo json_encode($output);

JSON

{"aaData":[{"Name":"apple","Position":"Office","Extn":"catnip","Start date":"catnip","Salary":"catnip"
}]}

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    Can you link to the page or use the DataTables debugger please.

    My guess is that your HTML has 6 columns defined in it.

    Allan

  • Art_MOO_styleArt_MOO_style Posts: 4Questions: 1Answers: 0

    Hello! Thanks a lot for ur answer! Here is the link for DataTables debugger data.
    http://debug.datatables.net/ucijum

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    My guess was correct - did you check that? Your table's HTML header has 6 columns in it. However the table's body and the columns array only have 5 columns defined.

    Allan

  • Art_MOO_styleArt_MOO_style Posts: 4Questions: 1Answers: 0
    edited July 2015

    Sorry but I don't get it. This is html:
    http://pastebin.com/UbVtQWV8
    Where your see that is 6?

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Answer ✓

    Doh sorry. I made a mistake in the deformatting of the HTML.

    The issue in in fact here:

    "aaData": "Name"

    And the other columns.

    There is no aaData option for columns. Use data (columns.data).

    Allan

  • Art_MOO_styleArt_MOO_style Posts: 4Questions: 1Answers: 0

    At last we will have revenge!! All works! Thanks a lot! U help me a lot!

This discussion has been closed.