简体   繁体   English

IE9上的jQuery表单插件问题

[英]Jquery form plug in issue on IE9

I am using JQuery Form plugin. 我正在使用JQuery Form插件。 In IE9, Sometimes I am getting "SCRIPT5: Access Denied" error on console.It works on Mozilla and Chrome. 在IE9中,有时我在控制台上收到“ SCRIPT5:访问被拒绝”错误。它在Mozilla和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. 表单:在我看来,这是一个隐藏的表单,我在文件类型输入控件的onchange事件上提交此表单。

<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?? 在IE9上出现问题?

thanks for help. 感谢帮助。

You can't do this $("#upload").val('') with file inputs in ie. 您无法使用ie中的文件输入来执行此$(“#upload”)。val('')。 The right way to clear it is to replace input with new one. 清除它的正确方法是用新输入替换输入。

$("#upload").replaceWith('<input type="file" id="upload" name="upload" onChange="submitFormOnFileSelection()"/>');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM