3
我正在使用Jquery的自动完成从mysql数据库中检索选项列表并在搜索时输出它们。但有时需要一分钟,所以我想在输入搜索查询时添加一个小的预加载gif。我搜索谷歌和这里,并没有找到我需要的答案。如果有人可以帮助,将不胜感激!这里是我的代码:将预加载器添加到jquery自动完成
JQUERY:
<script>
$(document).ready(function() {
$("#keywords").autocomplete({
source: keywordList,
minLength: 2,
select: function(event, ui){
$("#keywords").val(ui.item.value);
}
});
});
</script>
<?php echo keywordArray(); ?>
//这是从检索数据库中的数组并输出,这里是代码做到这一点:
function keywordArray()
{
$rsKeywords = mysql_query("SELECT Destination FROM Destinations WHERE Country = 'Mexico'");
$output = '<script>'."\n";
$output .= 'var keywordList = [';
while($row_rsKeywords = mysql_fetch_assoc($rsKeywords))
{
$output .= '"'.$row_rsKeywords['Destination'].'",';
}
$output = substr($output,0,-1); //Get rid of the trailing comma
$output .= '];'."\n";
$output .= '</script>';
return $output;
}
HTML:
<input id="keywords" name="keywords" type="text" autocomplete="off" size="40" >
没有工作..我加入这到CSS和没有发生在输入字段..谢谢你的尝试,但! – liveandream
@liveandream看到更新anwser – mgraph
非常感谢你!工作完美:) – liveandream