繁体   English   中英

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

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

我正在尝试将 json 对象下载为 cvs 文件。 这个 JSON 对象实际上是由浏览器本身中的 Java 对象组成的。 我不会触发任何网络请求来获取。
它在 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>

在控制台中,我得到了这个。

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

我在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';

恐怕你可以通过这种方式做到这一点。 Microsoft Internet Explorer 限制最多 2048 个字符的 URI。

相反,最好从不同的页面提供此 CSV 并指向 IE 从那里获取或使用msSaveOrOpenBlob示例:

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

*仅适用于 IE 10 及更高版本

暂无
暂无

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

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