我正在使用jquery 表单上传图像而无需刷新页面。以下是html标记:
    <a href="javascript:void(0);" onclick="UpdateImage();"> 
<img src="@_fullImgPath" name="img-uploader" alt="" title="" /></a>
    @using (Html.BeginForm("UpdateImage", "Profile", FormMethod.Post, new { id = "img-file-upload-form", @class = "form", autocomplete = "off", enctype = "multipart/form-data" }))
    {
        @Html.Hidden("UpdateImageId")
        <input type="file" name="file" id="file" />
    }
    <script language="javascript" type="text/javascript">   
     $(function () {
        $("#img-file-upload-form").ajaxForm({
            iframe: true,
            dataType: "json",
            beforeSubmit: function () {
            },
            success: function (result) {
                alert('done');
            },
            error: function (xhr, textStatus, errorThrown) {
                alert('error');
            }
        });
        $("#file").change(function () {
             $("#img-file-upload-form").submit();
        });
    });
     function UpdateImage(id) {
            $("input[id=file]").click();
        }
    </script>
这在 Firefox 和 Chrome 中运行良好,但在 IE 8 和 9 中,它会抛出拒绝访问错误。有什么解决办法吗?或者在不刷新页面的情况下上传图像的任何替代方法?