我尝试过但每次出现错误时都找不到,请帮帮我, json数据:
{ "siteList": [
{ "siteName": "Site1",
"deviceList": [
{ "deviceName": "S1device1", "count": "1" },
{ "deviceName": "S1device2", "count": "2" }
]
},
{ "siteName": "Site2",
"deviceList": [
{ "deviceName": "S2device1", "count": "1" },
{ "deviceName": "S2device2", "count": "2" }
]
},
{ "siteName": "Site3",
"deviceList": [
{ "deviceName": "S3device1", "count": "1" },
{ "deviceName": "S3device2", "count": "2" }
]
}
]
}
我想使用Datatable在html表格上显示它 这是html:
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>Site Name</th>
<th>Cabinet</th>
<th>Count</th>
</tr>
</thead>
</table>
还有Jquery:
$(document).ready(function() {
$('#example').DataTable( {
"ajax": "user.json",
"columns": [
{ "siteList": "siteName" },
{ "siteList": "deviceList:deviceName" },
{ "siteList": "deviceList:count" },
]
} );
} );
请帮助我做任何帮助,我们将不胜感激 预先感谢