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); 

原文地址:https://www.cnblogs.com/zlfucku/p/1965619.html