我使用jQuery Tokeninput(自动填充文本条目),但我无法显示结果,只显示“搜索”。我的代码是:
<input type="text" id="demo-input-pre-populated" name="blah" />
<script type="text/javascript">
$(document).ready(function () {
$("#demo-input-pre-populated").tokenInput("includes/jugadores_lista.php");
});
</script>
我的php
mysql_pconnect("host", "user", "pass") or die("Could not connect");
mysql_select_db("database") or die("Could not select database");
$query = sprintf("SELECT id, nombre from jugadores WHERE nombre LIKE '%%%s%%' ORDER BY id DESC LIMIT 10", mysql_real_escape_string($_GET["q"]));
$arr = array();
$rs = mysql_query($query);
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
$json_response = json_encode($arr);
if($_GET["callback"]) {
$json_response = $_GET["callback"] . "(" . $json_response . ")";
}
echo $json_response;
Php回归:
[{"id":"2","nombre":"Jugador 1},{"id":"1","nombre":"Jugador 2"}]
我做错了什么?我无法让它工作=( 谢谢,