开发者社区> 问答> 正文

只有firefor下可以显示进度条。。。IE,Google Chrome下都是不行的,只有整个for跑完才能显示出来...

<div class="adminMainTitle">
    <div class="adminSidebarTitleInternal">
        正在导入,请稍后....</div>
</div>
<div class="adminMainPanel">
    <textarea id="iting" cols="200" rows="20"></textarea>
</div>
<script>
    var hisIds = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
    $(document).ready(function () {
        if(hisIds.length==0){
            $("#iting").val("已导入");
            return;
        }
        setTimeout("go()",1000);
    });
    function go()
    {
        //导入
        for (var i = 0; i < hisIds.length; i++) {
           var id = hisIds[i];
           $.ajax({
              type: "POST",
              url: "Importting.aspx?ajax=true",
              data: "id="+id,
              async: false,
              success: function(msg){
                 
                $("#iting").val($("#iting").val() + "\r\n" + msg);
                document.getElementById("iting").scrollTop=document.getElementById("iting").scrollHeight;
              },
              error:function(msg)
              {
                $("#iting").val($("#iting").val() + "\r\系统异常");
              }
            });
        }
    }
</script>

只有firefor下可以显示进度条。。。IE,Google Chrome下都是不行的,只有整个for跑完才能显示出来...

谁有好的解决方案?

展开
收起
a123456678 2016-07-15 11:33:13 1964 0
1 条回答
写回答
取消 提交回答
  • timedProcessArray : function(items,process,callback){
    
    var todo = items.concat();
    
    setTimeout(function(){
    
    var start = +new Date();
    
    do{
    
    process(todo.shift());
    
    }while(todo.length>0 && +new Date()-start<50)
    
    if(todo.length>0)
    
    {
    
     setTimeout(arguments.callee,50);
    
    }else
    
    {
    
       if(callback)
    
    {
    
       callback(items);
    
    }
    
    }
    
    },50);
    
    }
    2019-07-17 19:56:49
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载