Jak*_*ake 8 jquery submit internet-explorer-8 blueimp jquery-file-upload
我正在使用Blue Imp jQuery File Uploader将文件上传到MVC控制器.这适用于所有浏览器,除了Internet Explorer 8,其中data.submit()似乎没有被触发.我已经为'data'添加了一个监视器,我可以在那里看到该文件,但是表单根本没有被提交.下面是我的插件代码的精简版:
$('#fileupload').fileupload({
dataType: 'json',
url: "Upload/Index",
limitConcurrentUploads: 1,
sequentialUploads: true,
add: function (e, data) {
var filename = data.files[0].name;
data.context = $('<div class="progress-container"></div>').text(filename).appendTo ($('#filelistholder'));
// Add a progress bar for the file
$('<div class=\"margin-b-10 progress-halved\"><div class="bar"></div></div>').appendTo(data.context);
// Add a new click event for the Upload All button and enable it
$('#btnUploadAll').removeAttr('disabled').click(function () {
// Submit the file and remove the click event
data.submit();
$('#btnUploadAll').off('click');
});
// Show how many files have been selected
$('#overallProgressText').text($('.progress-container').size() + ' file(s) selected');
},
progressall: function (e, data) {
// Update the Overall progress bar
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#overallbar').css('width', progress + '%');
// If all files have finished uploading disable the Upload All button
if (progress == 100) {
$('#btnUploadAll').attr('disabled', 'disabled');
}
},
progress: function (e, data) {
// Update the file's progress bar
var progress = parseInt(data.loaded / data.total * 100, 10);
data.context.find('.bar').css('width', progress + '%');
},
fail: function (e, data) {
$('#alertDivText').text('An unexpected error has occurred');
$('#AlertDiv').dialog({
title: "Alert",
buttons: {
Close: function () {
$(this).dialog("close");
}
},
modal: true,
closeOnEscape: true,
});
}
});
Run Code Online (Sandbox Code Playgroud)
注意:我使用的是jquery.iframe-transport.js和jquery-1.11.1
任何帮助将不胜感激,谢谢.
小智 0
已经在添加事件上注册的上传按钮提交事件怎么样?
像这样:
add: function (e, data) {
$('#buttonUpload').click(function (e) {
data.submit()
.error(function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
})
.complete(function (result, textStatus, jqXHR) {
//var fileCounterComplete = getUplFilesCount();
//fileCounter++;
//ajaxSubmit();
});
});
return false;
});
Run Code Online (Sandbox Code Playgroud)