我是javascript的noob,我想弄清楚如何从url中获取JSON数据并将其组织成关于本月的可视化表示。这里的问题是:从JSON url获取
数据:https://api.goodwillwa.org/stores?group_level=3
{
key: [
year,
month,
day
],
value: [
totalTransactions,
totalSales,
totalDiscounts,
totalItemsSold
]
}
目的:用客户端JavaScript获取JSON数据并按月创建 数据的可视化。你可以使用任何你觉得有用的库。为了简洁起见,加分。
我把一切都变成一个网页,并试图将它写出来的网页上:
<!DOCTYPE html)
<html>
<head>
<meta charset="utf-8">
<title>Code Test</title>
</head>
<body>
<h1 id="title">This is the month</h1>
<script>
function codeTest(key, value)
{
// code will fetch the json data structure and disply it in the html document
}
</script>
<p id="new"></p>
<button type="button" onclick="codeTest()"> Display information</button>
</body>
</html>
我想使它看起来空白,直到按下一个按钮,这将导致它显示在屏幕。谁能帮我吗?
你有什么试过?到目前为止,你有一个空的函数,编写了任何代码来尝试从远程URL加载? – shortstuffsushi
var url =“https://api.goodwillwa.org/stores?group_level=3”; $ .getJSON(url,function(data){ alert(data); }); 我对这种语言很陌生。我甚至还没有开始考虑如何在文档中格式化它。我只是想弄清楚如何检索信息。 – user3470798