1

如果问题标题是不够清楚:jQuery UI自动完成 - 如何实现进度指示器?

我使用jQuery自动完成插件(的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). 
    }}); 

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

很明显,在“选择”代码后,我可以隐藏图像,但我可以在哪里“显示”图像?

回答

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). 
    }}); 
+0

唉! (拍头)。当然。谢谢。 – RPM1984 2010-10-20 07:31:43

+0

那么图像又隐藏在哪里?不应该出现在$ .ajax({complete:....})或$ .ajax(...)。always(...)'中? – 2012-11-12 17:36:13

+0

嘿,我只是复制他的代码,并添加了两行来演示在ajax请求开始之前显示图像。他说:“很明显,在'选择'代码后,我可以隐藏图像,但我可以在哪里显示图像?”。我认为他隐藏了选择回调中的图像,并没有添加任何代码来隐藏图像。 – 2012-11-13 01:40:01