首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Internet Explorer 9和angular-file-upload无法正常工作

Internet Explorer 9和angular-file-upload无法正常工作
EN

Stack Overflow用户
提问于 2015-06-19 02:07:20
回答 1查看 2.5K关注 0票数 1

我正在尝试使用angular上传文件,除了在IE9上,它运行得很好。

我尝试过https://github.com/danialfarid/ng-file-upload,但在使用非HTML5浏览器时需要使用Flash,所以它不适用于我。

在那之后,我尝试了https://github.com/nervgh/angular-file-upload,并且工作了!除了上传文件后,我做了一些处理,可能会返回一个错误的错误请求。这在IE9中是行不通的。如果上传成功,我的代码看不到Bad Request。

好吧,我真的不认为问题出在我的代码上,所以我不会在这里发表任何东西。我想要的是一个有同样问题的人,让我知道该怎么做。

编辑:换句话说。在Chrome中,状态是400,在IE9中是200。

代码语言:javascript
复制
uploader.onCompleteItem = function (fileItem, response, status, headers)

EDIT2:我想我找到了错误的来源。这是一个角度文件上传函数

代码语言:javascript
复制
iframe.bind('load', function() {
   try {
   // Fix for legacy IE browsers that loads internal error page
   // when failed WS response received. In consequence iframe
   // content access denied error is thrown becouse trying to
   // access cross domain page. When such thing occurs notifying
   // with empty response object. See more info at:
   // http://stackoverflow.com/questions/151362/access-is-denied-error-on-accessing-iframe-document-object
   // Note that if non standard 4xx or 5xx error code returned
   // from WS then response content can be accessed without error
   // but 'XHR' status becomes 200. In order to avoid confusion
   // returning response via same 'success' event handler.

   // fixed angular.contents() for iframes
        var html = iframe[0].contentDocument.body.innerHTML;
     } catch (e) {}

         var xhr = {response: html, status: 200, dummy: true};
         var headers = {};
         var response = that._transformResponse(xhr.response, headers);

         that._onSuccessItem(item, response, xhr.status, headers);
         that._onCompleteItem(item, response, xhr.status, headers);

但我的回答总是模糊不清

EN

回答 1

Stack Overflow用户

发布于 2015-06-19 07:12:44

我想出了一个解决办法。在我的项目中,只有在服务器返回错误时,它才会输入catch语句。所以我在这里触发了事件onError。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30922652

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档