我有一个数据表和Json数据的问题。 Json看起来好,已验证,但不能获得数据表来处理。没有错误,虚无缥缈...... datatables不能正确Json
<table id="dtable3">
<thead>
<tr>
<th></th>
<th>Listing Id</th>
<th>Listing title</th>
<th>Calendar Id</th>
<th>Calendar Title</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>Listing Id</th>
<th>Listing title</th>
<th>Calendar Id</th>
<th>Calendar Title</th>
</tr>
</tfoot>
$(document).ready(function() {
var dt=<?php echo $jsonList?>;
$('#dtable3').DataTable({
"pageLength": 10,
data: dt,
// data:dat,
columns: [
{
"className": 'details-control',
"orderable": false,
data: null,
"defaultContent": "<span class='showBookings glyphicon glyphicon-list'></span><span class='editCal glyphicon glyphicon-pencil'></span>"
},
{data: 'listing_id'},
{data: 'title_1'},
{data: 'calendar_id'},
{data: 'calendar_title'},
],
});
广东话图什么不对的JSON或代码,因为我不明白的错误或其他任何东西... 谢谢为你的时间,非常感谢你的帮助。
你的代码工作正常,请参阅https://开头的jsfiddle。净/ qhyj1288/1 /。最有可能的问题是在这一行'var dt = <?php echo $ jsonList?>;'。您可以查看页面的源代码并发布PHP解释后实际显示的内容吗? –
@ Gyrocode.com,看到我现在更新的答案 - 他当然需要JSON.parse()它 - 愚蠢的我:( – davidkonrad