Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display ajax loading image

Tags:

jquery

I want to show ajax loading image. but don't know how to do that. here is my working ajax script. please help me to integrate ajax loading gif.thanks

$(function() { 
    $( "#slider" ).slider({ 
       stop: function(event, ui) {
              $.ajax({
              url: "ajax.php",
              cache: false,
              async: false,
             data: "",
                  success: function(html){
                $("#result_list").html(html);
              }
            });

         }
    });
});
like image 523
no_freedom Avatar asked May 26 '11 05:05

no_freedom


People also ask

How display loading image or loader when Ajax call is in progress?

You can display the image just before this call to $. ajax() and then hide/remove the image in the post handler function (just before your . empty()/. append(data) calls.

How do you show a loader until Ajax response?

Answer: Use the ajaxStart() and ajaxStop() MethodWhile working with Ajax, showing a loading spinner or displaying a message with some animation like "Loading... Please Wait" is popular way to indicate the user that Ajax request is in progress.

What is loader in Ajax?

jQuery - AJAX load() Method The load() method loads data from a server and puts the returned data into the selected element. Syntax: $(selector). load(URL,data,callback); The required URL parameter specifies the URL you wish to load.


1 Answers

$(function() { 
$( "#slider" ).slider({ 
   stop: function(event, ui) {
          $("#place_of_loading_image").show();
          $.ajax({
          url: "ajax.php",
          cache: false,
          async: false,
          data: "",
          success: function(html){ //got the data

            $("#place_of_loading_image").hide(); // hide ajax loader         
            $("#result_list").html(html);        // show downloaded content
          }
        });

     }
    });
});

Where #place_of_loading_image is some container (like div), in a place you would like loader.gif to appear.

<div id="place_of_loading_image" style="display:none"><img src="load.gif"/></div>
like image 120
MajesticRa Avatar answered Sep 18 '22 10:09

MajesticRa