Requested unknown parameter '0' for row 0
Requested unknown parameter '0' for row 0
Art_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
This discussion has been closed.
Answers
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
Hello! Thanks a lot for ur answer! Here is the link for DataTables debugger data.
http://debug.datatables.net/ucijum
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
Sorry but I don't get it. This is html:
http://pastebin.com/UbVtQWV8
Where your see that is 6?
Doh sorry. I made a mistake in the deformatting of the HTML.
The issue in in fact here:
And the other columns.
There is no
aaData
option for columns. Usedata
(columns.data
).Allan
At last we will have revenge!! All works! Thanks a lot! U help me a lot!