简体   繁体   English

将 Json 下载为文件:IE-11 throwing 414 Request-URI Too Large

[英]Download Json as file: IE-11 throwing 414 Request-URI Too Large

I am trying to download json object as cvs file.我正在尝试将 json 对象下载为 cvs 文件。 This JSON object is actually made out of a Java object that is in the browser itself.这个 JSON 对象实际上是由浏览器本身中的 Java 对象组成的。 I am not firing any network request to get.我不会触发任何网络请求来获取。
It is working fine in Chrome but IE-11 throws below error in Network->Response tab.它在 Chrome 中运行良好,但 IE-11 在 Network->Response 选项卡中引发以下错误。

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 
<html><head> 
<title>414 Request-URI Too Large</title> 
</head><body> 
<h1>Request-URI Too Large</h1> 
<p>The requested URL's length exceeds the capacity 
limit for this server.<br /> 
</p> 
<hr> 
<address>Omniture DC/2.0.0 Server at *.112.2O7.net Port 80</address> 
</body></html>

In the console , I am getting this.在控制台中,我得到了这个。

The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337

My code in javascripts is as below:我在javascripts中的代码如下:

  var fileName = "Group Assignment";
        var uri = 'data:text/csv;charset=utf-8,' + escape(CSV);
        var link = document.getElementById('download-as-csv');   
        link.href = uri;
        link.download = fileName + ".csv";
        link.innerHTML = 'Download as CSV';

I'm afraid you can do that in this way.恐怕你可以通过这种方式做到这一点。 Microsoft Internet Explorer has a limit up to 2048 characters for URIs. Microsoft Internet Explorer 限制最多 2048 个字符的 URI。

Instead it should be better you serve this CSV from a diferent page and point IE to get from there or use msSaveOrOpenBlob example:相反,最好从不同的页面提供此 CSV 并指向 IE 从那里获取或使用msSaveOrOpenBlob示例:

navigator.msSaveOrOpenBlob(new Blob(CSV.split('')), { type: 'text/csv' }), fileName + ".csv");

*works only from IE 10 and above *仅适用于 IE 10 及更高版本

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

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