首页 > 解决方案 > 将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);

标签: javascriptjqueryjsonwordpress

解决方案


推荐阅读