Javascript 如果出现错误,请重新加载

Javascript 如果出现错误,请重新加载,javascript,plupload,Javascript,Plupload,我正在尝试设置plupload,以便如果文件上传失败,根据某个错误代码,plupload将再次尝试上传它。没有成功 我目前拥有的 以下是我目前的一段代码: var attempts = 0; // number of attempts function init(uploader) { uploader.bind('Error', function(up, file) { var code = JSON.parse(file.response).error.code

我正在尝试设置plupload,以便如果文件上传失败,根据某个错误代码,plupload将再次尝试上传它。没有成功

我目前拥有的

以下是我目前的一段代码:

var attempts = 0; // number of attempts

function init(uploader) {

    uploader.bind('Error', function(up, file) {

        var code = JSON.parse(file.response).error.code;
        console.log(code); //logs the error code

        if(code === 503 && attempts > 3) {


            up.stop();
            file.status = plupload.FAILED;
            file.retry = false;

            // do stuff...

            up.state = plupload.STARTED;
            up.trigger("StateChanged");
            attempts = 0;
        }
        else {

            console.log("attempt : "+ attempts);
            up.stop();
            file.status = plupload.QUEUED;
            attempts++;
            file.retry = true;

            up.state = plupload.STARTED;
            up.trigger("StateChanged");
            up.trigger("QueueChanged"); // ERROR HERE
        }
    })
}
在我指出“此处出错”的地方,我的控制台显示:

TypeError:n.getSource不是函数

我做错了什么


非常感谢

为什么不将文件再次添加到队列中?


为什么不将文件再次添加到队列中?


嘿,谢谢你这么说,但它不是在尝试,它只是没有增加。有什么建议吗?这只是你代码的一部分吗?如果是的话,请用剩下的代码更新它。嘿,谢谢,但它不是在尝试,它只是不增加。有什么建议吗?这只是你代码的一部分吗?如果是,请用剩余的代码更新。
addFile(file, [fileName])