将json文件发送到服务器

时间:2018-05-16 14:19:43

标签: javascript jquery json wordpress

我正在尝试将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);

0 个答案:

没有答案