jQuery未完成显示

jQuery未完成显示,jquery,autocomplete,Jquery,Autocomplete,我已经浏览了很多以前的帖子,但是我认为我的比我发现的要简单得多。我的字段已成功请求数据,但未显示数据。我假设这与CSS相关,以显示它。我正在使用jQuery UI CSS来显示它,就像我在设计的其他网站上所做的那样: <link href="/css/console/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" /> 这里是我试图展示它的地方。我做错了什么?我在其他网站上也做过 <input typ

我已经浏览了很多以前的帖子,但是我认为我的比我发现的要简单得多。我的字段已成功请求数据,但未显示数据。我假设这与CSS相关,以显示它。我正在使用jQuery UI CSS来显示它,就像我在设计的其他网站上所做的那样:

<link href="/css/console/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" />
这里是我试图展示它的地方。我做错了什么?我在其他网站上也做过

<input type="text" name="userSearch" id="userSearch"/>
<input class="button" style="top: -1px; margin-left: 5px;" type="button" value="SEARCH" />
<input type="hidden" id="hiddenUserWom" value="" /></span></div>
      <script type="text/javascript" src="/js/jquery-ui-1.8.18.custom.min.js"></script>
      <script type="text/javascript">
      $('#userSearch').autocomplete({
            source: '/console/ajax/user_search_autocomplete.php',
            minLength: 3,
            select: function (event, ui) {
                $("#userSearch").val(ui.item.label); 
                $("#hiddenUserWom").val(ui.item.id);
        }
      });

      $(document).ready( function () {
          $("#userSearch").focus();
      });
      </script>
以下是成功返回的数据: 这是一个返回的示例:

[{标签:5U5NU-Devin Parker-Vacaville,CA,id:5U5NU}]

来自官方网站的jQuery UI数据格式说明:

预期数据格式

来自本地数据、url或回调的数据可以分为两种 变体:

字符串数组:[Choice1,Choice2]具有 标签和值属性:[{label:Choice1,value:value1}, …]

这应该能正常工作

以下是网站:


需要自动完成的是power search字段。

将自动完成放入$document中。准备好了吗

<input type="text" name="userSearch" id="userSearch"/>
<input class="button" style="top: -1px; margin-left: 5px;" type="button" value="SEARCH" />
<input type="hidden" id="hiddenUserWom" value="" /></span></div>
  <script type="text/javascript" src="/js/jquery-ui-1.8.18.custom.min.js"></script>
  <script type="text/javascript">


  $(document).ready( function () {
  $('#userSearch').autocomplete({
        source: '/console/ajax/user_search_autocomplete.php',
        minLength: 3,
        select: function (event, ui) {
            $("#userSearch").val(ui.item.label); 
            $("#hiddenUserWom").val(ui.item.id);
    }
  });
      $("#userSearch").focus();
  });
  </script>
问题2$userSearch.valui.item.label;
您正在用自己的数据覆盖autocomplete。

问题在于PHP返回的数据。如果您尝试完全相同的方法,但使用数组中的固定集作为源,则自动完成功能将非常完美

JSON编码似乎很好


我知道您不需要或使用它,但请尝试为每个项目添加一个值。我不确定,但该值可能是必填字段,您可以比我更容易地对其进行测试。

为什么输入字段上的属性autocomplete=off?不起作用。数据被成功返回,但没有显示。@mavrick-数据在哪里?我没有将其应用于任何字段。在您的选择中,请尝试使用alertui.item。label@harhahu-如果要从中选择的列表从未出现,则不会执行Select。我需要显示结果列表。@harhahu-我想你不明白这是怎么回事。有人能帮我吗?显然,我希望在select上的搜索字段中显示单击元素的值。这里还会发生什么?