php mysql wordpress自动完成不工作
问题描述:
我已经链接到相应的自动完成和jQuery的ajax库。这里是脚本php mysql wordpress自动完成不工作
jQuery(document).ready(function($) {
$("#tag").autocomplete("data.php", {
selectFirst: true
});
});
和我data.php文件
$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']."\n";
}
}
和我的形式
<label>Tag:</label>
<input name="tag" type="text" id="tag" size="20"/>
的data.php文件被成功加载comnames的数组但是当我输入我什么都没有...
答
jquery noconflict包装
jQuery(document).ready(function($) {
$("#tag").autocomplete("data.php", {
selectFirst: true
});
});
参考:http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers
更新:
您还需要使用AJAX
答
jQuery库中的“无冲突包括与WordPress负荷检索源“模式。这样做是为了防止与其他JavaScript库的兼容性问题。在“无confict”模式下,$快捷方式不可用的时间越长jQuery是使用,例如:
jQuery的(文件)。就绪(函数($){
哇,感谢您的快速响应!不幸的是,它仍然没有工作... 这里是data.php结果 http://hotspotbirding.com/blog/wp-content/themes/Western/data.php – 2013-04-03 22:04:03