如何在ajax中添加加载效果 [英] How to add loading effects in ajax
本文介绍了如何在ajax中添加加载效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前我有这段代码可以在点击时从外部 PHP 获取数据,但它显示我需要的是加载效果的一些延迟,我尝试了 jQuery 淡入缓慢,但它对我不起作用
Currently I have this code that gets the data from external PHP whenever clicked but it shows to quick what I need is that some delay with loading effects, I tried jQuery fade In Slow but it didn't work for me
$(document).ready(function() {
$("#display").click(function() {
$.ajax({ //create an ajax request to load_page.php
type: "GET",
url: "o.php",
dataType: "html", //expect html to be returned
success: function(response){
$("#responsecontainer").fadeIn('slow').html(response);
//alert(response);
}
});
});
});
推荐答案
这样你就可以减慢你的输出.
this way you can slowdown your output.
$(document).ready(function() {
$("#display").click(function() {
$.ajax({ //create an ajax request to load_page.php
type: "GET",
url: "o.php",
dataType: "html", //expect html to be returned
success: function(response){
setTimeout(function({
$("#responsecontainer").fadeIn('slow').html(response)
},100);
}
});
});
});
这篇关于如何在ajax中添加加载效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文