Let the storm money come!

jquery 队列的应用

        View Code
  本人要上传四个文件,但是上传里暂时没支持并列上传,所以只能排队,但是考虑到我的界面一些调整,只能用同步等待,但又不能阻塞别的线程,所以只能用上述代码。 
     var _fnList = [function () { $("body").append(levelFn.length + ' : 1'); }, 
            
function () { $("body").append(levelFn.length + '2'); },
            
function () { $("body").append(levelFn.length + '3'); }, 
            
function () { $("body").append(levelFn.length + '4'); } ];
        
var levelFn = $(document).queue("fnList", _fnList);
//        for (var i = 0; i < 4; i++) {
//
            $(document).dequeue("fnList");
//
        }
        var bk = function () {
            $(document).dequeue(
"fnList");
        };

        setInterval(bk, 
5000);

        
//

 

// 使用闭包,存下先前的数据       
 var _fnList = [];
        
var barcode = [];
        
for (var i = 1; i <= 4; i++) {
            
//$(document).dequeue("fnList");
            //barcode[i] = i;
            _fnList.push((function () {
                
var temp = i;
                
var exe = function () {
                    $(
"body").append(levelFn.length + ' : ' + temp + "<br />");
                }
                
return exe;
            })());
        } 
        
var levelFn = $(document).queue("fnList", _fnList);
        
var bk = function () {
            $(document).dequeue(
"fnList");
        };

        setInterval(bk, 5000); 

posted @ 2011-02-26 11:13  精密~顽石  阅读(219)  评论(0编辑  收藏  举报
在通往地狱的路上,加班能使你更快到达。