gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-27 23:03:22 24 4
gpt4 key购买 nike

我正在尝试将 json 对象下载为 cvs 文件。这个 JSON 对象实际上是由浏览器本身中的 Java 对象组成的。我不会触发任何网络请求来获取。
它在 Chrome 中工作正常,但 IE-11 在“网络”->“响应”选项卡中抛出以下错误。

<!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

我的 JavaScript 代码如下:

  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 有一个limit up to 2048 characters对于 URI。

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

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

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

关于javascript - 下载 Json 文件 : IE-11 throwing 414 Request-URI Too Large,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36841820/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com