我创建了两个功能 1-为ajax电话 2-表示X秒后的更新信息
但是我需要根据JSON中的信息创建(变量)并在图表中将其用于功能 ....例如
function ajaxGetApi() {
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
var myJson = JSON.parse(xhr.responseText);
//console.log(myJson + "" + myJson.user.length);
//---------------------------------------
// var userName = myJson.user[i].userName;
// var cases_count = myJson.user[i].cases_count;
console.log("--------------------------------");
var status_id0 = myJson.status[0].status_id;
var status_count0 = myJson.status[0].count;
var status_id1 = myJson.status[1].status_id;
var status_count1 = myJson.status[1].count;
var status_id2 = myJson.status[2].status_id;
var status_count2 = myJson.status[2].count;
console.log(status_id0 + "-" + status_count0);
console.log(status_id1 + "-" + status_count1);
console.log(status_id2 + "-" + status_count2);
console.log("--------------------------------");
var gender_id = myJson.gender[i].gender_id;
var gender_count = myJson.gender[i].count;
console.log("--------------------------------");
var prov_id = myJson.prov[i].province_id;
var prov_count = myJson.prov[i].count;
console.log("--------------------------------");
var reg_id = myJson.reg[i].reg_id;
var reg_count = myJson.reg[i].count;
console.log("--------------------------------");
//---------------------------------------
}
});
xhr.open("GET", "data.php");
xhr.send(data);
}
function updateInfo() {
ajaxGetApi();
setInterval(ajaxGetApi, 60000);
}
updateInfo();
thanx求助:)