Por que os dataTables do jQuery não podem analisar meu JSON?
Eu estou tentando preencher umTabela de dados do seguinte modo:
$("#my-datatable").dataTable( {
"sAjaxSource" : "/someURLOnMyServer",
"bDestroy" : true,
"fnServerParams" : function(serverParams) {
serverParams.push(
{
"name" : "widget",
"value" : token
}
);
}
});
E a tabela HTML que está sendo preenchida:
<table id="my-datatable">
<thead>
<tr>
<th>Type</th>
<th>Value</th>
<th>ID</th>
<th>Fizz</th>
<th>Buzz</th>
</tr>
</thead>
<tbody></tbody>
</table>
De acordo com o Firebug, o JSON voltando do servidor é:
[
{
"id":1,
"attributeType":{
"id":1,
"name":"test1",
"tag":"test-type",
"is-dog":false
},
"attributeValue":{
"id":null,
"name":"blah",
"tag":"BLAH"
},
"buzz":1,
"fizz":"53abc"
}
]
Mas o Firebug está jogando o seguinte erro de JavaScript em seu console:
TypeError: aData is undefined
[Break On This Error]
for ( i=0 ; i<aData.length ; i++ ) --> jquery.dataTables.js (line 2541)
Alguém pode ver o que está errado? Ou eu não estou configurando meudataTable
objeto corretamente, ou o retorno do JSON não corresponde ao "esquema" da tabela HTML que está tentando preencher. De qualquer forma, estou perdido. Desde já, obrigado!