我有一個數據表和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