xmlHttpRequest 挂起错误仅在 Chrome 中发生发送大型 json-23kb 时

问题描述

如果您在如下编码后进行测试,则会出现随机 xhr 未决错误。 这主要发生在发送大型 json 数据时。 当http body区域被删除然后传输时,服务器出现408响应似乎是一个问题。 这不是服务器问题。从浏览器发送数据时缺少 http 正文的问题。 任何人在使用大量 json 数据进行测试时都会遇到这种情况。 这是随机发生的。 此外,这只发生在最新的 chrome 浏览器中。 有什么解决办法吗?

var xmlhttp = new XMLHttpRequest();
var theUrl = "http://localhost:8080/backoffice/service/fee/insertAgreementData";
xmlhttp.open("POST",theUrl);
xmlhttp.timeout = 3000; // time in milliseconds
xmlhttp.setRequestHeader("Content-Type","application/json;charset=UTF-8");
xmlhttp.send(JSON.stringify(large json data));

chrome develope tool

fail status

success status

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)