我有巨大的文件要在服务器上处理。我将文件上传到服务器,然后读取它,制作数组。现在我需要将该信息放回服务器:
function getXMLFile(file){ // Single call
$.ajax({
url: '....',
type: 'post',
dataType: 'json',
data: {filename: file},
success: function(json){
$.each(json, function( key, value ){ // iterates over 50 000 items.
tmp.push( value );
i++;
if(i > 10000){
setTimeout(function(){
insert(tmp);
tmp = [];
i = 0;
}, 1000);
}
});
}
});
}
这是锁定功能:
function insert(data){ // called from getXMLFile() @data -> array of 10 000 code entries
$.ajax({
url: '....', // for now php function does nothing.
type: 'post',
dataType: 'json',
data: {codes: data},
async: true // !!!!
});
}
});
如您所见,我有'async:true'并使用setTimeout,这样我的浏览器就不会被锁定。但它仍然锁定......我做错了什么吗?