문제

If the question title wasn't clear enough:

I am using the jQuery AutoComplete plugin (part of jQuery UI 1.8.5)

I would have thought the supplied CSS/images would include an ajax-like progress image?

If not, what's the easiest way to create one?

This is my autocomplete code:

$('#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).
   }});

Where should i hide/show an image in the above code?

Obviously after the code in "select", i could hide an image, but where can i "show" the image?

도움이 되었습니까?

해결책

$('#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