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