对于这个问题,我一点都不熟悉javascript或编程。但是,尽管如此,我确实设法完成了艰巨的任务。我想知道,是否有适当或更实际的方式来做到这一点?预先感谢您的帮助。如果有人想知道的话,这是用于队列管理系统的。
var requestURL = 'https://api.qminder.com/v1/tickets/search/?rest-api-key=APIKEY'
var request = new XMLHttpRequest();
request.open('GET', requestURL);
request.responseType = 'json';
request.send();
request.onload = function() {
var customers = request.response;
console.log(customers.data)
x = []
for (var i = 0; i < customers.data.length; i++) {
console.log(customers.data[i].status);
if (customers.data[i].status == "NEW") {
x.push(customers.data[i])
}
}
var html = '<ul>';
for (var i = 0; i < x.length; i++) {
html += '<li>' + x[i].firstName + '</li>';
console.log(x[i].firstName)
}
html += '</ul>';
document.getElementById("names").innerHTML = html;
}
window.setInterval(function() {
var requestURL = 'https://api.qminder.com/v1/tickets/search/?rest-api-key=APIKEY'
var request = new XMLHttpRequest();
request.open('GET', requestURL);
request.responseType = 'json';
request.send();
request.onload = function() {
var customers = request.response;
console.log(customers.data)
x = []
for (var i = 0; i < customers.data.length; i++) {
console.log(customers.data[i].status);
if (customers.data[i].status == "NEW") {
x.push(customers.data[i])
}
}
var html = '<ul>';
for (var i = 0; i < x.length; i++) {
html += '<li>' + x[i].firstName + '</li>';
console.log(x[i].firstName)
}
html += '</ul>';
document.getElementById("names").innerHTML = html;
}
}, 2000);
子衿沉夜
相关分类