【发布时间】: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