【发布时间】:2012-02-15 16:07:45
【问题描述】:
我想使用带有 php 文件作为源的 jquery 自动完成“功能”。我不明白为什么它不起作用。如果我使用在变量中输入的数据,一切正常。希望有人可以提供帮助。预先感谢您的回复。干杯。马克。
我的 HTML:
<input id="moi" type="text"/>
我的 JS:
$(function() {
$( "#moi" ).autocomplete({
source: "php/search_loc.php",
minLength: 2
});
});
我的 PHP:
<?php
header('Content-Type: text/html; charset=utf-8');
require("../inc/connect.inc.php");
mysql_set_charset('utf8');
$result = mysql_query("SELECT * FROM search_loc");
$row=mysql_fetch_assoc($result);
while($row=mysql_fetch_assoc($result)){
echo $row['srl_loc'].'<br>';}
?>
【问题讨论】:
-
我从未使用过 jQuery 自动完成插件,但我相当确定它没有被
<br>分隔。 -
你有两次
$row=mysql_fetch_assoc($result);。这是故意的吗?
标签: php jquery autocomplete