我有以下JS代码:
var response = loadXMLDoc();
var dataset = response.data;
alert(response);
alert (dataset);
“警报(响应)”打印:
{"labels":["-inf - 10","10 - 20","20 - 30","30 - 40","40 - 50","50 - 60","60 - 70","70 - 80","80 - 90","90 - 100","100 - 110","110 - 120","120 - 130","130 - 140","140 - 150","150 - 160","160 - +inf"],"data":[3,8,7,3,7,6,6,7,5,4,10,7,4,4,7,2,0],"count":16}
而“警报(数据集)”给出“未定义”。我试过用
var dataset = response["data"];
但它也没有奏效。我想从 JSON 对象中获取数据数组。我怎样才能做到这一点。谢谢