I am using JQuery Form plugin. In IE9, Sometimes I am getting "SCRIPT5: Access Denied" error on console.It works on Mozilla and Chrome. here is my code:
Form: its a hidden form on my view and i am submitting this form on onchange event of file type input control.
<form id="fileAttachment" action="@Url.Action("AttachFile", "Attachment")" method="post" enctype="multipart/form-data">
<input type="file" id="upload" name="upload" onChange="submitFormOnFileSelection()"/>
<input type="submit" id="xxx" name="asd" />
</form>
Code to submit form:
$(document).ready(function () {
var options = {
beforeSend: function () {
},
uploadProgress: function (event, position, total, percentComplete) {
},
success: function () {
},
complete: function(response) {
$("#AttachmentArea").html(response.responseText);
},
error: function () {
$("#AttachmentArea").html("<font color='red'> ERROR: unable to upload files</font>");
}
};
$("#fileAttachment").ajaxForm(options);
});
function submitFormOnFileSelection() {
if ($("#upload").val() != '') {
$('#fileAttachment').submit(function() {
$("#fileAttachment").ajaxSubmit(options);
});
$("#upload").val('');
}
}
Problem occurs on IE9??
thanks for help.
You can't do this $("#upload").val('') with file inputs in ie. The right way to clear it is to replace input with new one.
$("#upload").replaceWith('<input type="file" id="upload" name="upload" onChange="submitFormOnFileSelection()"/>');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.