【发布时间】:2011-03-31 16:15:04
【问题描述】:
我有这个弹出输入选择器的 jquery 代码,它应该显示如下:
$("#demo-input-pre-populated").tokenInput("http://shell.loopj.com/", {
prePopulate: [
{id: 123, name: "Slurms MacKenzie"},
{id: 555, name: "Bob Hoskins"},
{id: 9000, name: "Kriss Akabusi"}
]
});
当我尝试使用 php 从数据库中获取 vales 时:
prePopulate: [
<?
$responses = array();
$topicJSON=getQtopics($getQ);
while($row = mysql_fetch_array($topicJSON)){
$response = array(
'id' => $row['id'],
'name' => $row['name']
);
$responses[] = $response;
}
echo json_encode($responses);
?>
],
这样显示 json 数据:
prePopulate: [
[{"id":"1","name":"Dormitree"},
{"id":"1482","name":"carriage of goods"}]
],
但是在#demo-input-pre-populated" 输入上我得到了未定义,我认为它的 php 没有回显 json propelrly,我该如何解决这个问题:))
【问题讨论】: