【发布时间】:2020-12-15 05:55:39
【问题描述】:
我正在尝试通过我在它旁边创建的 .js 文件来编辑 .json 文件。 我正在使用 ajax 调用从我的 .json 文件中获取数据,但对于编辑我不知道该怎么做,这是我获取数据的代码:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
objects =JSON.parse(xhttp.responseText) ;
}
};
xhttp.open("GET", "object.json", true);
xhttp.send();
这也是我的 .json 文件:
{
"circles":[
{ "id":1 ,
"cx":100,
"cy":100,
"r":50,
"stroke":"green" ,
"strokeWidth":4,
"fill":"yellow"
},
{
"id":2 ,
"cx":30,
"cy":30,
"r":10,
"stroke":"green" ,
"strokeWidth":4,
"fill":"yellow"
}
]
}
请给我一个线索 谢谢你们:))
【问题讨论】:
标签: javascript ajax