码迷,mamicode.com
首页 > 其他好文 > 详细

根据后台加载数据,添加loading动画

时间:2018-07-06 11:23:24      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:key   info   item   没有   ref   inf   内容   arch   time   

<script>
var current = 0;
var hit = @hits;
$(this).scroll(function(){
var viewHeight =$(this).height();//可见高度
var contentHeight =$(".search_content").get(0).scrollHeight;//内容高度
var scrollHeight =$(this).scrollTop();//滚动高度

if(contentHeight - viewHeight < scrollHeight) {
if(current<hit)
{
$(".loading").css("display","block");
$.ajax({
url: "",
data:{
SearchKey:"",
current:current+15
},
async:true,
success: function(result){
var strhtml ="";
for (item in result.data)
{
strhtml += " <div class=‘info‘>";
if (result.data[item].TitleFormat!="")
{
strhtml += " <a href=‘‘ target=‘_blank‘ class=‘ifone‘>" +  + "</a>";
}
else {
strhtml += " <a href=‘‘ target=‘_blank‘ class=‘ifone‘>" +  + "</a>";
}
strhtml += " <div class=‘oneimg‘>";
strhtml += " <img src=‘/Content/img/searchBg.png‘ class=‘img-responsive‘ />";
strhtml += " </div>";
strhtml += " <div class=‘infobtm‘>";
strhtml += " <span></span>";
strhtml += " <span>"+ result.data[item].PublishTime +"</span>";
strhtml += " <span></span>";
strhtml += " </div>";
strhtml += " </div>";
}

$(".search_content").append(strhtml);

}});
}else{
$(".loading").html("已经到底部了...");
}

}else{
$(".loading").css("display","none");
}
});


var contentif = $(‘div‘).is(‘.search_content‘);   //判断是否含有该类
if(contentif == true){
$(".loading").css("display","none");
}else{
$(".loading").addClass("loadingnoinfo");
$(".loading img").css("display","none");
$(".loading").html("没有搜索到内容 ...");
}

</script>

根据后台加载数据,添加loading动画

标签:key   info   item   没有   ref   inf   内容   arch   time   

原文地址:https://www.cnblogs.com/quitpoison/p/9272194.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!