[英]jQuery show div loading onclick
单击时需要我的jQuery的建议,在页面加载前显示div加载。 我测试了代码,但未显示div加载。
到目前为止,这是我的代码:
$(".taskss3").click(function(evt)
{
$('#status_random').show();
var get_uid = $(this).attr("id");
$("#randomdiv").load("load_auto.php?uid="+ get_uid)
{
$('#status_random').hide();
$('#randomdiv').show();
}
});
的HTML
<div id="status_random"></div>
<div id="randomdiv"></div>
的CSS
#status_random
{
background: url('../../assets/images/processing.gif');
height: 24px;
width: 24px;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
margin-bottom: 10px;
}
请帮忙!
您需要使用回调
$(".taskss3").click(function (evt) {
$('#status_random').show();
var get_uid = this.id;
$("#randomdiv").load("load_auto.php?uid=" + get_uid, function () {
//do this in the load callback
$('#status_random').hide();
$('#randomdiv').show();
})
});
在您的代码中,您将在调用load()
立即隐藏加载程序,而无需等待加载完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.