看了一百万个帖子但找不到实际的解决方案。我正在寻找一个解决方案或确认这是我必须处理的IE11错误。尝试使用ajax表单数据发布图像。在IE11以外的每个浏览器中都能完美运行(不关心其他版本的IE)。无论我尝试什么帖子只是处于待处理状态,如下所示:
有时它会完成但需要100多秒才能完成,这根本不理想。
任何人都知道如何使用插件或其他上传图片的方法来解决这个问题?
我的代码:
var inputField = $(e.target);
var rxContainer = $(e.target).closest('.image-preview-container');
var uploadBtn = $(rxContainer).find('.fileinput-button');
var uploadBtnTxt = $(uploadBtn).find('span');
var base64Text = $(rxContainer).find('.base64Text');
var imageAccessKey = $(rxContainer).find('.AccessKey-div').find('input');
var image = $(inputField).data('image');
var blobFile = inputField[0].files[0];
var fd = new FormData();
fd.append('file', blobFile);
fd.append('nothing', 'nothing');
//disable buttons during upload
$(inputField).prop('disabled', true);
$(uploadBtn).css('opacity', '0.3');
$(':submit').prop('disabled', true);
$(':submit').css('opacity', '0.3');
var xhr;
var uploadImage = function () {
showLoadingDialog();
xhr = $.ajax({
url: Urls.rximageuploadapi,
headers: {
'Authorization': 'Bearer ' + image
},
type: 'POST',
data: fd ? fd : inputField.serialize(),
processData: false,
contentType: false,
cached: false,
success: function(response) {
//load image access key into form
imageAccessKey.val(response.imageAccessKey);
//load returned image into preview window
loadImage(response.image, rxContainer);
$(base64Text).html(response.image);
//re-enable buttons after upload
$(inputField).prop('disabled', false);
$(uploadBtn).css('opacity', '1');
$(':submit').prop('disabled', false);
$(':submit').css('opacity', '1');
hideLoadingDialog();
},
error: function(jqXHR, textStatus, errorMessage) {
//display error message
clearCanvas(rxContainer);
uploadBtnTxt.text(Resources.CHOOSEPHOTO_MESSAGE);
$maxFileSizeError.hide();
$maxFileTypeError.hide();
if (jqXHR.status == "500") {
var errorResponse = jqXHR.responseText;
var jsonResponse = JSON.parse(errorResponse);
if (jsonResponse.errors != undefined && jsonResponse.errors.length > 0) {
for (var i = 0; i < jsonResponse.errors.length; i++) {
var errorText = jsonResponse.errors[i].message;
if (errorText == "BLANK_IMAGE" || errorText == "CORRUPTED_FILE") {
$corruptedFile.show();
break;
} else if (errorText == "PASSWORD_PROTECTED") {
$passwordProtectedFile.show();
break;
}
}
} else {
$fileUploadError.show();
}
} else {
$fileUploadError.show();
}
//re-enable buttons after upload
$(inputField).prop('disabled', false);
$(uploadBtn).css('opacity', '1');
$(':submit').prop('disabled', false);
$(':submit').css('opacity', '1');
hideLoadingDialog();
}
});
}