douqiang3768 2015-02-17 19:11
浏览 50

JQuery Autocomplete不能使用PHP

Hi does anyone have any ideas why my JQuery autocomplete is not bringing back any results?

Here is the PHP code:

$result = mysql_query("SELECT * FROM stations where StationName like '%" .     mysql_real_escape_string($_GET['term']) . "%'");

$array = array();

while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

 $row_array[] = $row['StationName'];
 array_push($array, $row_array);
}

echo json_encode($array);

Here is the JS code:

$(function() {

$('#location').val("");

$("#location").autocomplete({

    source: "autocomplete.php",
    minLength: 2,
    select: function(event, ui) {
        $("#location").val(ui.item.location);
    }

 });
});

And finally the HTML:

<input type='text' class="suggest" id='location'>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突