i have this jquery code which poplautes a input selector, which should display like this:
$("#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"}
]
});
when i try get the vales from the database using php like this:
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);
?>
],
which displays the json data like this:
prePopulate: [
[{"id":"1","name":"Dormitree"},
{"id":"1482","name":"carriage of goods"}]
],
but on the #demo-input-pre-populated"
input i get undefined, and i think its becuase php is not echoing the json propelrly, how can i fix this thanks :))