【发布时间】:2012-05-08 22:22:03
【问题描述】:
我正在尝试让 tag-it jquery 插件与 json 字符串一起使用。 目前我正在像这样从数据库中获取我的值:
$query = sprintf(
'SELECT
t.tag
FROM
tags AS t
');
$row_set= array();
if($result = mysqli_query($db, $query))
{
// fetch data
while ($row = mysqli_fetch_assoc($result))
{
$row_set[] = $row;
}
// set the output
echo json_encode($row_set);
}
在 AJAX 中调用时会给出以下输出:
[{"tag":"test"},{"tag":"tests"}]
但我必须以以下格式输出 JSON 字符串:
["android-intent","animate","architecture","artificial-intelligence","attributes"]
我怎样才能做到这一点?
【问题讨论】:
标签: php mysql ajax json tag-it