0
我的表未正確通過ajax加載。jQuery DataTables POST服務器端Json錯誤
這裏是我的JS:
$('#initAjaxDataTable').DataTable({
"pagingType": "full_numbers",
"processing": true,
"serverSide": true,
"ajax": {
"url": $('#initAjaxDataTable').data('url'),
"type": "POST"
},
language: {
url: SITEURL + 'libraries/datatables/datatables.german.json'
},
"columnDefs": [
{ "data": "adressnummer", "defaultContent": "<i>Keine</i>", "targets": 0 },
{ "data": "name", "defaultContent": "<i>Keine</i>", "targets": 1 },
{ "data": "email", "defaultContent": "<i>Keine</i>", "targets": 2 },
{ "data": "street", "defaultContent": "<i>Keine</i>", "targets": 3 },
{ "data": "zip", "defaultContent": "<i>Keine</i>", "targets": 4 },
{ "data": "city", "defaultContent": "<i>Keine</i>", "targets": 5 }
]
});
這裏是我的JSON從服務器返回:
{"draw":1,"data":"[{"DT_RowId".........:}]","recordsTotal":24301,"recordsFiltered":50,"error":null}
數據簡單的例子:
[
{
"DT_RowId": "row_1",
"adressnummer": "9002",
"name": "test data",
"email": "",
"street": "test 26",
"zip": "16307 ",
"city": "test",
"DT_RowData": {
"pkey": "1"
}
},
{
"DT_RowId": "row_2",
"adressnummer": "9003",
"name": "test data",
"email": "",
"street": "test 24",
"zip": "16306 ",
"city": "test",
"DT_RowData": {
"pkey": "2"
}
},
{
"DT_RowId": "row_3",
"adressnummer": "9006",
"name": "testtest data",
"email": "",
"street": "test17",
"zip": "16306 ",
"city": "test",
"DT_RowData": {
"pkey": "3"
}
},
......
我的表:
<table class="table table-striped table-bordered " id="initAjaxDataTable" data-page-length="50" data-url="/importlist">
<thead>
<tr>
<th>AdressNummer</th>
<th>Name</th>
<th>E-Mail</th>
<th>Strasse</th>
<th>PLZ</th>
<th>Ort</th>
</tr>
</thead>
</table>
我的表顯示24301次每個列中的默認內容。
我使用jQuery的數據表中的1.10.9版本和jQuery在 版本2.1.4
什麼,我做錯了什麼?
編輯:Json的林特說我的JSON是有效
或者可能只是''dataSrc「:」「' – annoyingmouse
nope在我的情況下這沒有做 – Tanktiger