次のようにdataTableにデータを入力しようとしています:
$("#my-datatable").dataTable( {
"sAjaxSource" : "/someURLOnMyServer",
"bDestroy" : true,
"fnServerParams" : function(serverParams) {
serverParams.push(
{
"name" : "widget",
"value" : token
}
);
}
});
そして、それが入力している HTML テーブル:
<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>
Firebug によると、サーバーから返される JSON は次のとおりです。
[
{
"id":1,
"attributeType":{
"id":1,
"name":"test1",
"tag":"test-type",
"is-dog":false
},
"attributeValue":{
"id":null,
"name":"blah",
"tag":"BLAH"
},
"buzz":1,
"fizz":"53abc"
}
]
しかし、Firebug はコンソールに次の JavaScript エラーをスローしています。
TypeError: aData is undefined
[Break On This Error]
for ( i=0 ; i<aData.length ; i++ ) --> jquery.dataTables.js (line 2541)
誰が何が問題なのかを見つけることができますか? オブジェクトを正しく設定していないdataTable
か、返された JSON が入力しようとしている HTML テーブルの「スキーマ」と一致しません。いずれにせよ、私は迷っています。前もって感謝します!