uploader 上传文件,当在上传过程中断开网络,异常无法处理。
我在调试时候打印出,文件已经上传的大小,与文件总大小。当文件上传到一定比率,突然断开网络,控制台打印出 ‘Uncaught SyntaxError: Unexpected token }’这样的语句!????关键是这个异常我不知道怎样捕获?下面是我监听 uploader的 onStateChanged事件的函数:
function onStateChanged( upload, status ) {
try
{
var percent = parseInt((upload.uploadedSize/upload.totalSize)*100);
//var percent = 20;
console.log(upload.uploadedSize + "," + upload.totalSize);
if (!isNaN(percent)){
if (10<percent<100){
progress.style.width = percent + "%" ;
}else if (percent == 100){
//width: 50% auto;
progress.style.width = percent + "% auto" ;
}
progresstxt.innerText = percent+"%";
//alert(filesSizeInf[0].name + "," +filesSizeInf[0].size);
if (finishFileCount<filesSizeInf.length && upload.uploadedSize >= filesSizeInf[finishFileCount].size){
finishinfo.innerText = "已经上传" + (++finishFileCount)+"/" +files.length+"张";
//alert("已经上传" + finishFileCount+"张,共" +files.length+"张,文件名称");
}
}
//alert('完成比率:' + percent);
if ( upload.state == 4) {
//alert( "Upload success: " + upload.getFileName());
if (status == 200){
files=[];
document.getElementById("imgList").innerHTML = "";
}
}
}catch (e){
alert("状态错误" + e.message);
}
}
tanjsong
一直得不到解决,郁闷啊,我今天又发问了,还是uploader的这个问题:求救 http://ask.dcloud.net.cn/question/5401
2015-05-14 22:42