gpt4 book ai didi

javascript - 使用javascript读取json

转载 作者:行者123 更新时间:2023-11-28 16:11:29 25 4
gpt4 key购买 nike

我正在服务器上发送一些请求,它回复我:

{
"count": 100,
"entries": [
{
"id": 7563,
"application": "my-app",
"user": "admin",
"time": "2012-10-10T11:32:09.324+07:00",
"values": {
"/my-app/name": "4d79f56b-1a20-4b25-bff6-b5f1d7253790"
}
},
{
"id": 7561,
"application": "my-app",
"user": "admin",
"time": "2012-10-10T11:32:08.687+07:00",
"values": {
"/my-app/name": "4d79f56b-1a20-4b25-bff6-b5f1d7253790"
}
}
}

我尝试过,但似乎没有任何效果!

 var my_JSON_object = {};
var xmlhttp = new XMLHttpRequest();

my_JSON_object = JSON.parse(xmlhttp.responseText);

xmlhttp.open("GET",url,true);
xmlhttp.sand();

一切都很好。但返回 null。
任何帮助将不胜感激!

[my code]

最佳答案

更正您的代码:

 xmlhttp.open("GET",url,false);
xmlhttp.send();

//get response after sending request
my_JSON_object = JSON.parse(xmlhttp.responseText);

关于javascript - 使用javascript读取json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12815390/

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