阿贾克斯文件上传在IE7中不工作 [英] Ajax file upload not working in IE7

查看:172
本文介绍了阿贾克斯文件上传在IE7中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个插件,通过Ajax在asp.net MVC3文件上传。
http://malsup.com/jquery/form/#ajaxSubmit
但它不会在IE7中工作。

I've used this plugin for file upload via Ajax in asp.net mvc3. http://malsup.com/jquery/form/#ajaxSubmit But it won't work in IE7.

$("#Controls").submit(function () {
            var options = {
                url: "/Education/upDoc",
                datatype: "json",
                success: showResponse
            };
    $(this).ajaxSubmit(options);
});

function showResponse(responseText, statusText, xhr, $form) {
        alert("sr");
        alert("Sr  " + responseText.success);
        if (responseText.success == true) {
            //some code
        }
    }

<form action='' id='Controls' method='post' enctype='multipart/form-data'>
<table>
                        <tr> 
                        <td>File Type</td> 
                        <td><span class='leftten'></span></td> 
                        <td> 
                        @*<select id='documentType' name='documentType'> 

                        </select> *@
                        @Html.DropDownList("documentType", doctypelist, new { @id = "documentType" })
                        </td> 

                        <td><img src='../../img/AlertSign.jpg'  class='errImgDoc' data-style-tooltip='tooltip-shiny-red' title='' id='errFileType'  height='18px' width='20px'/></td> 
                        <td><span class='leftfortytwo'></span></td> 
                        <td><input type='file' id='file' name='file' /></td> 
                        <td><img src='../../img/AlertSign.jpg'  class='errImgDoc' data-style-tooltip='tooltip-shiny-red' title='' id='errFile'  height='18px' width='20px' /></td> 
                        <td><span class='leftfortytwo'></span></td> 
                        <td>Name</td> 
                        <td><span class='leftten'></span></td> 
                        <td><input type='text' id='description' name='description' /></td> 
                        </tr> 
                        </table> 
                        <br /> 
                        <div align='right'> 
                        <table><tr> 
                        <td><input type='button' id='eduUploadCancel' class='Cancel' onmouseover='CancelHover(this)' onmouseout='CancelMouseOut(this)' onclick='Cancel(this)' /></td><td><span class='leftten'></span></td><td><input type='submit' id='eduUploadSave' class='Save' onmouseover='SaveHover(this)' onmouseout='SaveMouseOut(this)' /></td></tr></table> 
                        </div>

</form>

在这里, showResponse方法()永远不会被调用与IE7。做工精细的Chrome和Firefox.Please帮助!

Here,showResponse() is never called with IE7. Works fine on Chrome and Firefox.Please help!

推荐答案

IE 7是旧的浏览器不支持XMLHtt prequest 2级。

IE 7 is old browser and not support XMLHttpRequest Level 2.

有关老的浏览器,回退技术被用于涉及
  因为它内部框架是不可能用1级上传文件
  在XMLHtt prequest对象implmenentation。这是一种常见的
  回退的技术,但它具有固有的局限性。在iframe
  元素作为表单提交的目标而
  也就是说,服务器响应写入到iframe中。这可以
  如果响应类型是HTML或XML,但是如果不工作,以及
  类型是script或JSON,
这两者往往含有
  需要的字符使用实体引用时repesented
  一些HTML代码。

For older browsers, a fallback technology is used which involves iframes since it is not possible to upload files using the level 1 implmenentation of the XMLHttpRequest object. This is a common fallback technique, but it has inherent limitations. The iframe element is used as the target of the form's submit operation which means that the server response is written to the iframe. This is fine if the response type is HTML or XML, but doesn't work as well if the response type is script or JSON, both of which often contain characters that need to be repesented using entity references when found in HTML markup.

http://malsup.com/jquery/form/#file-upload

这篇关于阿贾克斯文件上传在IE7中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆