我想显示ajax加载图像。但不知道该怎么做。这是我的工作 ajax 脚本。请帮我 集成ajax加载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);
}
});
}
});
});
最佳答案
$(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
}
});
}
});
});
其中 #place_of_loading_image 是某个容器(例如 div),位于您希望 loader.gif 出现的位置。
<div id="place_of_loading_image" style="display:none"><img src="load.gif"/></div>
关于jquery - 如何显示ajax加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6134110/