当前位置:u赢电竞手机版 > u赢电竞竞猜app > ajax加载时的进度条,ajax加载进度条u赢电竞竞猜

ajax加载时的进度条,ajax加载进度条u赢电竞竞猜

文章作者:u赢电竞竞猜app 上传时间:2019-05-18

最终效果如下图所示,pc和移动端都可以展示的,调用方法也很简单,开始调用:loading.baosight.showPageLoadingMsg(false),alse代表不现实加载说明,true展示加载说明.调用完成后调用:loading.baosight.hidePageLoadingMsg(),在整个代码里有两个文件,一个是js文件,一个是css文件。切记不要忘记引入jquery.js

ajax加载时的进度条,ajax加载进度条

运行效果如下图,pc和移动都可以展示,调用方法很简单,开始调用:loading.baosight.showPageLoadingMsg(false),false代表不现实加载说明,true展示加载说明.调用完成后调用:loading.baosight.hidePageLoadingMsg(),有两个文件,一个是js文件,一个是css文件.别忘记引入jquery.js哦.想了解更多的可以加qq群:106320003

u赢电竞竞猜app 1

css文件

#_loadMsg{
    display: inline-block;
    width: 100%;
    text-align: center;
    line-height: 45;
    padding-left: 20px;
    display : none;
}

#_loading_div {
     vertical-align: middle;
    display: inline-block;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    text-align: center;
    position: absolute;
    z-index: 3;
    line-height: 40;
    opacity: 0.5;
    display : none;
    background: #CCCCCC;
}

#_loading_div span {
    display: inline-block;
    width: 10px;
    height: 40px;
    animation-name: scale;
    -webkit-animation-name: scale;
    -moz-animation-name: scale;
    -ms-animation-name: scale;
    -o-animation-name: scale;
    animation-duration: 1.2s;
    -webkit-animation-duration: 1.2s;
    -moz-animation-duration: 1.2s;
    -ms-animation-duration: 1.2s;
    -o-animation-duration: 1.2s;
    animation-iteration-count: infinite;
    -webkit-animation-iteration-count: infinite;
    -moz-animation-iteration-count: infinite;
    -ms-animation-iteration-count: infinite;
    -o-animation-iteration-count: infinite;
}
span.item-1 {
  background: #2ecc71;
}
span.item-2 {
  background: #3498db;
}
span.item-3 {
  background: #9b59b6;
}
span.item-4 {
  background: #e67e22;
}
span.item-5 {
  background: #c0392b;
}
span.item-6 {
  background: #e74c3c;
}
span.item-7 {
  background: #e74c8c;
}

.item-1 {
    animation-delay: -1s;
    -webkit-animation-delay: -1s;
    -moz-animation-delay: -1s;
    -ms-animation-delay: -1s;
    -o-animation-delay: -1s;
}

.item-2 {
    animation-delay: -0.9s;
    -webkit-animation-delay: -0.9s;
    -moz-animation-delay: -0.9s;
    -ms-animation-delay: -0.9s;
    -o-animation-delay: -0.9s;
}

.item-3 {
    animation-delay: -0.8s;
    -webkit-animation-delay: -0.8s;
    -moz-animation-delay: -0.8s;
    -ms-animation-delay: -0.8s;
    -o-animation-delay: -0.8s;
}

.item-4 {
    animation-delay: -0.7s;
    -webkit-animation-delay: -0.7s;
    -moz-animation-delay: -0.7s;
    -ms-animation-delay: -0.7s;
    -o-animation-delay: -0.7s;
}

.item-5 {
    animation-delay: -0.6s;
    -webkit-animation-delay: -0.6s;
    -moz-animation-delay: -0.6s;
    -ms-animation-delay: -0.6s;
    -o-animation-delay: -0.6s;
}

.item-6 {
    animation-delay: -0.5s;
    -webkit-animation-delay: -0.5s;
    -moz-animation-delay: -0.5s;
    -ms-animation-delay: -0.5s;
    -o-animation-delay: -0.5s;
}

.item-7 {
    animation-delay: -0.4s;
    -webkit-animation-delay: -0.4s;
    -moz-animation-delay: -0.4s;
    -ms-animation-delay: -0.4s;
    -o-animation-delay: -0.4s;
}

@-webkit-keyframes scale {
  0%, 40%, 100% {
    -moz-transform: scaleY(0.2);
    -ms-transform: scaleY(0.2);
    -o-transform: scaleY(0.2);
    -webkit-transform: scaleY(0.2);
    transform: scaleY(0.2);
  }

  20%, 60% {
    -moz-transform: scaleY(1);
    -ms-transform: scaleY(1);
    -o-transform: scaleY(1);
    -webkit-transform: scaleY(1);
    transform: scaleY(1);
  }
}
@-moz-keyframes scale {
  0%, 40%, 100% {
    -moz-transform: scaleY(0.2);
    -ms-transform: scaleY(0.2);
    -o-transform: scaleY(0.2);
    -webkit-transform: scaleY(0.2);
    transform: scaleY(0.2);
  }

  20%, 60% {
    -moz-transform: scaleY(1);
    -ms-transform: scaleY(1);
    -o-transform: scaleY(1);
    -webkit-transform: scaleY(1);
    transform: scaleY(1);
  }
}
@-ms-keyframes scale {
  0%, 40%, 100% {
    -moz-transform: scaleY(0.2);
    -ms-transform: scaleY(0.2);
    -o-transform: scaleY(0.2);
    -webkit-transform: scaleY(0.2);
    transform: scaleY(0.2);
  }

  20%, 60% {
    -moz-transform: scaleY(1);
    -ms-transform: scaleY(1);
    -o-transform: scaleY(1);
    -webkit-transform: scaleY(1);
    transform: scaleY(1);
  }
}
@keyframes scale {
  0%, 40%, 100% {
    -moz-transform: scaleY(0.2);
    -ms-transform: scaleY(0.2);
    -o-transform: scaleY(0.2);
    -webkit-transform: scaleY(0.2);
    transform: scaleY(0.2);
  }

  20%, 60% {
    -moz-transform: scaleY(1);
    -ms-transform: scaleY(1);
    -o-transform: scaleY(1);
    -webkit-transform: scaleY(1);
    transform: scaleY(1);
  }
}

 

js文件

var loading = {
        baosight : {
            showPageLoadingMsg : function(showMessage){
                if($("#_loading_div").length == 0){
                    $("body").append('<div id="_loading_div"></div>');
                }
                if($("#_loadMsg").length == 0){
                    $("body").append('<div id="_loadMsg">正在加载,请稍候... ...</div>');
                }
                if(showMessage == true || showMessage == "true" ){
                    $("#_loadMsg").show();
                }
                $("#_loading_div").show();
            },
            hidePageLoadingMsg :function() {
                $("#_loading_div").hide();
                $("#_loadMsg").hide();
            }
        }
}

 

u赢电竞竞猜app 2

ajax loading 进度条

没见过
编程思路,挑选几个点人工判断进度,此外恐怕没有更好的办法了。
<script>
function setProcess(n)
{//表现进度条脚本
}
setProcess(10)//设置进度条10%
</script>
<html>
....
<script>
setProcess(30)//设置进度条30%
</script>
....
<script>
setProcess(50)//设置进度条50%
</script>
....
<script>
setProcess(70)//设置进度条70%
</script>
....
<script>
setProcess(90)//设置进度条90%
</script>
.....
<script>
setProcess(100)//设置进度条100%
window.setTimeout("porcessDiv.innerHTML=''",500)//0.5秒后关闭进度条div
</script>  

css文件

用JQuery实现页面Loading的效果,即:当页面加载完成前显示Loading的进度条,全部加载完成之后进度条消失

二楼的方法不是常规的解决办法,个人感觉不是很好(不过他实现的加载进度是真实的,他的进度条是可以反映当前未加载页面的剩余内容的---其实这种方法也挺好....不过一般情况下没什么必要吧,如果要做成这样的,用flex更好)。
一楼的方法不是正确的。如果简单地放一个loading图片在页面上的话,会有两种情况:一、有可能实现加载的效果 。 二、在整个页面其它元素加载了大部分或全部后,这张图片才加载进来,那就实现不了加载的效果了。

常规的解决办法还是用ajax比较好。大概是这样的。
需要两个页面。1.一个是实际页面本身 2.另一个是一个空白页面放一张loading图片
先请求第2个页面,在这个页面中放一段ajax请求第1个页面,在success函数里将页面内容输出,并将loading图片隐藏掉。
代码是这样的:
loading page:
<body>
<img id='loadingImg' src='loading.gif' />
<body>
<script>
$.ajax({
type: 'GET',
url: 实际页面路径,
data: {},
success: function(){
$('body').append(data);
$('#loadingImg').hide();//或直接remove()
},
dataType: 'html'
});
</script>

==========================================================
呵呵,一个加载的问题要考虑搜索的话原来就这么麻烦了。 <div id="forspider">.....给搜索蜘蛛看的纯HTML....</div>这里面的内容是整个实际页面的HTML吗?是的话,那这个loading页面本身加载就很笨重了,还不如直接跳到真实页面呢。 哎,可惜我不太懂搜索,悲剧。请指教----为什么要用绝对定位覆盖的方法来隐藏。直接把这一层display:none的话蜘蛛也会看不到吗?  

运行效果如下图,pc和移动都可以展示,调用方法很简单,开始调用:loading.baosight.showPageLoadingMsg(false),false代...

#_loadMsg{
 display: inline-block;
 width: 100%;
 text-align: center;
 line-height: 45;
 padding-left: 20px;
 display : none;
}

#_loading_div {
 vertical-align: middle;
 display: inline-block;
 width: 100%;
 height: 100%;
 margin: 0 auto;
 text-align: center;
 position: absolute;
 z-index: 3;
 line-height: 40;
 opacity: 0.5;
 display : none;
 background: #CCCCCC;
}

#_loading_div span {
 display: inline-block;
 width: 10px;
 height: 40px;
 animation-name: scale;
 -webkit-animation-name: scale;
 -moz-animation-name: scale;
 -ms-animation-name: scale;
 -o-animation-name: scale;
 animation-duration: 1.2s;
 -webkit-animation-duration: 1.2s;
 -moz-animation-duration: 1.2s;
 -ms-animation-duration: 1.2s;
 -o-animation-duration: 1.2s;
 animation-iteration-count: infinite;
 -webkit-animation-iteration-count: infinite;
 -moz-animation-iteration-count: infinite;
 -ms-animation-iteration-count: infinite;
 -o-animation-iteration-count: infinite;
}
span.item-1 {
 background: #2ecc71;
}
span.item-2 {
 background: #3498db;
}
span.item-3 {
 background: #9b59b6;
}
span.item-4 {
 background: #e67e22;
}
span.item-5 {
 background: #c0392b;
}
span.item-6 {
 background: #e74c3c;
}
span.item-7 {
 background: #e74c8c;
}

.item-1 {
 animation-delay: -1s;
 -webkit-animation-delay: -1s;
 -moz-animation-delay: -1s;
 -ms-animation-delay: -1s;
 -o-animation-delay: -1s;
}

.item-2 {
 animation-delay: -0.9s;
 -webkit-animation-delay: -0.9s;
 -moz-animation-delay: -0.9s;
 -ms-animation-delay: -0.9s;
 -o-animation-delay: -0.9s;
}

.item-3 {
 animation-delay: -0.8s;
 -webkit-animation-delay: -0.8s;
 -moz-animation-delay: -0.8s;
 -ms-animation-delay: -0.8s;
 -o-animation-delay: -0.8s;
}

.item-4 {
 animation-delay: -0.7s;
 -webkit-animation-delay: -0.7s;
 -moz-animation-delay: -0.7s;
 -ms-animation-delay: -0.7s;
 -o-animation-delay: -0.7s;
}

.item-5 {
 animation-delay: -0.6s;
 -webkit-animation-delay: -0.6s;
 -moz-animation-delay: -0.6s;
 -ms-animation-delay: -0.6s;
 -o-animation-delay: -0.6s;
}

.item-6 {
 animation-delay: -0.5s;
 -webkit-animation-delay: -0.5s;
 -moz-animation-delay: -0.5s;
 -ms-animation-delay: -0.5s;
 -o-animation-delay: -0.5s;
}

.item-7 {
 animation-delay: -0.4s;
 -webkit-animation-delay: -0.4s;
 -moz-animation-delay: -0.4s;
 -ms-animation-delay: -0.4s;
 -o-animation-delay: -0.4s;
}

@-webkit-keyframes scale {
 0%, 40%, 100% {
 -moz-transform: scaleY(0.2);
 -ms-transform: scaleY(0.2);
 -o-transform: scaleY(0.2);
 -webkit-transform: scaleY(0.2);
 transform: scaleY(0.2);
 }

 20%, 60% {
 -moz-transform: scaleY(1);
 -ms-transform: scaleY(1);
 -o-transform: scaleY(1);
 -webkit-transform: scaleY(1);
 transform: scaleY(1);
 }
}
@-moz-keyframes scale {
 0%, 40%, 100% {
 -moz-transform: scaleY(0.2);
 -ms-transform: scaleY(0.2);
 -o-transform: scaleY(0.2);
 -webkit-transform: scaleY(0.2);
 transform: scaleY(0.2);
 }

 20%, 60% {
 -moz-transform: scaleY(1);
 -ms-transform: scaleY(1);
 -o-transform: scaleY(1);
 -webkit-transform: scaleY(1);
 transform: scaleY(1);
 }
}
@-ms-keyframes scale {
 0%, 40%, 100% {
 -moz-transform: scaleY(0.2);
 -ms-transform: scaleY(0.2);
 -o-transform: scaleY(0.2);
 -webkit-transform: scaleY(0.2);
 transform: scaleY(0.2);
 }

 20%, 60% {
 -moz-transform: scaleY(1);
 -ms-transform: scaleY(1);
 -o-transform: scaleY(1);
 -webkit-transform: scaleY(1);
 transform: scaleY(1);
 }
}
@keyframes scale {
 0%, 40%, 100% {
 -moz-transform: scaleY(0.2);
 -ms-transform: scaleY(0.2);
 -o-transform: scaleY(0.2);
 -webkit-transform: scaleY(0.2);
 transform: scaleY(0.2);
 }

 20%, 60% {
 -moz-transform: scaleY(1);
 -ms-transform: scaleY(1);
 -o-transform: scaleY(1);
 -webkit-transform: scaleY(1);
 transform: scaleY(1);
 }
}

本文由u赢电竞手机版发布于u赢电竞竞猜app,转载请注明出处:ajax加载时的进度条,ajax加载进度条u赢电竞竞猜

关键词: