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);
}
});
}
});
});
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.
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.
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.
$(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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With