jQuery UI AutoComplete - 如何实现进度指示器?

时间:2010-10-20 06:34:56

标签: jquery jquery-ui jquery-ui-autocomplete progress-indicator

如果问题标题不够明确:

我正在使用jQuery AutoComplete插件(jQuery UI 1.8.5的一部分)

我原以为提供的CSS /图像会包含类似ajax的进度图像吗?

如果没有,创建一个最简单的方法是什么?

这是我的自动填充代码:

$('#query').autocomplete({
   source: function (request, response) {
      $.ajax({
         url: "/Search/FindLocations",
         type: "POST",
         dataType: "json",
         data:
         {
            searchText: request.term
         },
         success: function (data) {
            response($.map(data, function (item) {
               return { name: item.name, value: item.name }
            }))
         }),
   select: function (event, ui) {
      // snip... (this is where i display stuff about what they clicked).
   }});

我应该在上面的代码中隐藏/显示图像?

显然,在“选择”中的代码之后,我可以隐藏图像,但我可以在哪里“显示”图像?

1 个答案:

答案 0 :(得分:3)

$('#query').autocomplete({
   source: function (request, response) {
      //i would show the image here, before starting your ajax request
      $("#theImage").show();
      $.ajax({
         url: "/Search/FindLocations",
         type: "POST",
         dataType: "json",
         data:
         {
            searchText: request.term
         },
         success: function (data) {
            response($.map(data, function (item) {
               return { name: item.name, value: item.name }
            }))
         }),
   select: function (event, ui) {
      // snip... (this is where i display stuff about what they clicked).
   }});
相关问题