Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 向jquery自动完成添加预加载程序_Php_Jquery_Autocomplete_Preloader - Fatal编程技术网

Php 向jquery自动完成添加预加载程序

Php 向jquery自动完成添加预加载程序,php,jquery,autocomplete,preloader,Php,Jquery,Autocomplete,Preloader,我使用Jquery的autocomplete从mysql数据库中检索选项列表,并在搜索时输出它们。但有时需要一分钟,所以我想在输入搜索查询时添加一个小的预加载gif。我已经搜索了谷歌和这里,但没有找到我需要的答案。如果有人能帮忙,我将不胜感激!这是我的密码: JQUERY: <script> $(document).ready(function() { $("#keywords").autocomplete({ source: keywordList, minLe

我使用Jquery的autocomplete从mysql数据库中检索选项列表,并在搜索时输出它们。但有时需要一分钟,所以我想在输入搜索查询时添加一个小的预加载gif。我已经搜索了谷歌和这里,但没有找到我需要的答案。如果有人能帮忙,我将不胜感激!这是我的密码:

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:

在css中添加以下内容:

.ui-autocomplete-loading { background:url('img/indicator.gif') no-repeat right center }
将img/indicator.gif替换为图像预加载路径,如果希望预加载位于左侧,也可以从右向左进行更改

js:


不起作用。。我将其添加到css中,但在输入字段中没有发生任何事情。。谢谢你的尝试!非常感谢你!工作完美:我必须在jquery-ui.css文件中添加这个吗?。如果是这样,它就不起作用了..我找不到这样的类..我正在使用jquery-ui-v1.9.2版本..@Lakshmanan请检查这个
.ui-autocomplete-loading { background:url('img/indicator.gif') no-repeat right center }
$("#keywords").autocomplete({
    source: keywordList,
    minLength: 2,

    search  : function(){$(this).addClass('ui-autocomplete-loading');},
    open    : function(){$(this).removeClass('ui-autocomplete-loading');},

    select: function(event, ui){
        $("#keywords").val(ui.item.value);
        }