如果问题标题还不够清楚:

我正在使用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).
   }});

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

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

有帮助吗?

解决方案

$('#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).
   }});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top