我正在使用bootstrap表插件,似乎无法将其加载到表中。我之前已经成功使用过它,但无法弄清楚我在这里做错了什么。行数正在通过,所以我知道引导表正在读取JSON数据,只是表中的值都是空的。我认为JSON格式正确,字段名称都是一致的。有任何想法吗?
Javacript
function populate_quote_table()
{
$('#quote_table').bootstrapTable({
onSearch: function (text) {
},
onLoadSuccess: function (data) {
console.log(data);
//$('#test').html(data);
},
url: "<?php echo $site_url?>/quotes.php",
striped: true,
search: true,
showRefresh:true,
showColumns:true,
pagination: true,
showFilter: true,
columns: [{
field: 'QID',
title: 'QID',
}, {
field: 'CID',
title: 'Customer ID',
}, {
field: 'Distance',
title: 'Distance',
}]
});
};
});
PHP
$i = 0;
$quotes[] = array();
if ($result) {
while($row = mysql_fetch_array($result)) {
$quotes[$i]['"QID"'] = $row['quote_id'];
$quotes[$i]['"CID"'] = $row['customer_id'];
$quotes[$i]['"Distance"'] = $row['distance'];
$i++;
}
}
echo json_encode($quotes);
JSON输出
[
{
"QID": "1",
"CID": "1",
"Distance": "1"
},
{
"QID": "2",
"CID": "2",
"Distance": "11"
},
{
"QID": "3",
"CID": "20",
"Distance": "5"
},
{
"QID": "4",
"CID": "21",
"Distance": "67"
}
]
答案 0 :(得分:0)
不需要额外报价
原创 - $ quotes [$ i] [&#39;&#34; QID&#34;&#39;] = $ row [&#39; quote_id&#39;];
工作 - $ quotes [$ i] [&#39; QID&#39;] = $ row [&#39; quote_id&#39;];