【问题标题】:Multiple instances of blueimp's jQuery File Upload with IE 8blueimp 的 IE 8 jQuery 文件上传的多个实例
【发布时间】:2015-02-03 22:03:33
【问题描述】:

我在使用 blueimp 的 jQuery File Upload 时遇到了一个奇怪的情况。

我的代码就这么简单:

<div><input type="file" name="files" id="f1"></div>
<div><input type="file" name="files" id="f2"></div>


<script>
$("input:file").each(function () {
    $(this).fileupload({
        url: "./?a=upload&t=",
        dataType: 'json',

        add: function (e, data) {
            alert("add");
            /* same as default implementation */
            if (data.autoUpload || (data.autoUpload !== false &&
                    $(this).fileupload('option', 'autoUpload'))) {
                data.process().done(function () {
                    data.submit();
                });
            }
        },

        start: function (e) {
            alert("start");
        }
    });
});
</script>

在 Firefox 和 Chrome 中一切正常:单击任何输入字段时,会显示“添加”和“开始”消息并提交请求。

在 IE 8 中似乎创建了两个实例(加载页面时没有错误),但是当我单击文件输入并选择要上传的文件时,只显示“添加”消息,然后 IE 触发错误:

cannot call methods on fileupload prior to initialization; attempted to call method 'process'

页面中只有一个文件输入控件可以正常工作,所以我猜这个问题一定与多个实例有关。

我正在使用 jQuery 上传插件 9.8.1 和 jQuery 1.11.1。

提前致谢。

【问题讨论】:

    标签: jquery internet-explorer-8 upload blueimp


    【解决方案1】:

    用 IE8 尝试了演示页面 (here),它不起作用(尽管演示页面声称它应该)。

    【讨论】:

    • 我这里有同样的行为,演示页面在 IE 8 中不起作用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    • 2012-09-06
    • 1970-01-01
    • 1970-01-01
    • 2020-04-25
    • 1970-01-01
    相关资源
    最近更新 更多