douzang7928 2013-04-03 21:44 采纳率: 100%
浏览 44

php mysql wordpress自动完成无法正常工作

I have linked to the appropriate ajax library for autocomplete and jquery. Here is the script

 jQuery(document).ready(function($) {
 $("#tag").autocomplete("data.php", {
  selectFirst: true
   });
  });

and my data.php file

    $q = $_GET["q"];
   $my_data=mysql_real_escape_string($q);
  $sql="SELECT comname FROM wp_birds WHERE comname LIKE '%$my_data%' ORDER BY comname";
  $result = mysql_query($sql) or die(mysql_error());
  if($result)
  {
   while($row=mysql_fetch_array($result))
    {
   echo $row['comname']."
";
   }
 }

and my form

<label>Tag:</label>
<input name="tag" type="text" id="tag" size="20"/>

the data.php file is successfully loading the array of comnames however when i input i'm getting nothing...

  • 写回答

2条回答 默认 最新

  • dougudu3564 2013-04-03 21:53
    关注

    jquery noconflict wrapper

    jQuery(document).ready(function($) {
        $("#tag").autocomplete("data.php", {
          selectFirst: true
        });
    });
    

    reference: http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers

    Update:

    You also need to retrieve your source using ajax

    http://jqueryui.com/autocomplete/#remote

    评论

报告相同问题?

悬赏问题

  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了