对于你们中的一些人来说这可能很容易,但是自从第一次这样做以来对我来说非常困难。
通过查看网络上的一些示例,我最终得到了以下代码的自动建议示例,但代码不起作用。
谢谢
HTML
$(document).ready(function() { $('#textbox_postcode').autocomplete( { source: 'search-db.php', minLength: 3 }); });
PHP
$ keyword = ltrim(strtolower(strip_tags($ _ GET [‘keyword’])));
if(!$ keyword)返回;
$ host =’localhost’; $ user =’root’; $ pswd =”; $ dtbs =’geomaps’;
$ host_conn = mysql_connect($ host,$ user,$ pswd); $ dtbs_conn = mysql_select_db($ dtbs);
$ return = array();
$ sql =“SELECT id,postcode FROM postcodes WHERE postcode LIKE’$ keyword%’ORDER BY postcode”; $ run = mysql_query($ sql);
if(@mysql_num_rows($ run)== 0)return;
while($ records = mysql_fetch_array($ run,MYSQL_ASSOC)){$ return [] = $ records; }
echo json_encode($ return);
尝试将$_GET['keyword']
更改$_GET['term']
以上就是jQuery教程分享jquery自动建议示例不起作用相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/jquerytutorial/547346.html