Cant work with JSOn
Cant work with JSOn
Hello,
im new and very confused.
I generate a table with ajax. It works for me, with this settings:
$(document).ready(function() {
$('#myTable').DataTable({
ajax: {
"url": "helper/ajax.alle_ezb.php",
"dataSrc": ""
},
"order": [[2, 'asc']],
"columns": [{
"data": "id",
"visible": false
},
{
"data": "vorname"
},
{
"data": "nachname"
}
]
});
});
I have a normal JSON:
[{"id":"409","ElternID":"839","nachname":"ALLL","vorname":"DDDDDD","Sorgeberechtigt":"0
But, when i change the JSON Output with a Name, like
{"result":[
[
{"id":"409","ElternID":"839","nachname":"ALLLL","vorname":"DDDDD","Sorgeberechtigt":"0"
and Change the Script to
$(document).ready(function() {
$('#myTable').DataTable({
ajax: {
"url": "helper/ajax.alle_ezb.php",
"dataSrc": "result"
},
"order": [[2, 'asc']],
"columns": [{
"data": "id",
"visible": false
},
{
"data": "vorname"
},
{
"data": "nachname"
}
]
});
});
i become the error
DataTables warning: table id=myTable - Requested unknown parameter 'id' for row 0, column 0.
Requested unknown parameter 'vorname' for row 0, column 1
I dont know why. I have search over hours, will try some other code, but no will accept.
Why i become a error for id and vorname, but not nachname.
when i will work with data:0 , data:1, data:2 it dont will work. also result:0,...
The JSON is valide. In my opinion the change to result will be work, but in reality, it isnt right.
This question has an accepted answers - jump to answer
Answers
Looks like you have two levels of arrays which won't work:
Remove the 2nd array level then it should work.
Kevin
Kevin,
you make my Day.
Great, iam a blind turtel.