javascript - 将json文件发送到服务器
问题描述
我正在尝试将 json 文件发送到服务器 url。我没有收到任何错误,但是当我输入网址时,它是空的。
$('#form-output code').html(JSON.stringify(params, undefined, 4));
var xhr = new XMLHttpRequest();
var url = "https://netfish.xyz/wp-
content/uploads/2018/05/archivo.json";
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var json = JSON.parse(xhr.responseText);
}
};
var data = JSON.stringify(params, undefined, 4);
console.log('eeeeee');
console.log(data);
xhr.send(data);
解决方案
推荐阅读
- perl - 如果在一起,如何将两个下一个结合起来
- python - Python 错误:IndexError:使用 Selenium 进行抓取时列表索引超出范围
- python - 初始化 MCI python 时出现问题
- c++ - 架构 x86_64 的未定义符号:编译错误
- multithreading - 使用 powershell 在多台计算机上监控特定进程的最快方法
- android - 如何使用导航 ui 组件中的底部工作表对话框
- rust - 打印从根到叶的所有路径
- java - 发布到 url 并在输出上运行可调用的 Java 方法
- sql - 将数据从多个表插入临时表
- html - 如何扩展 facebook div 以在左侧边栏中查看完整的组名