2014-09-01 84 views
0

需要你的意见与我的jQuery点击,显示加载页面前的div加载。我测试了代码,但div加载不显示。jQuery显示div加载onclick

这里是我到目前为止的代码:

$(".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; 
} 

请帮帮忙!

回答

2

您需要使用回调

$(".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()被称为无需等待加载完成隐藏装载机。