我正在使用bl.ocks.org中的d3js样本来绘制图表。有一个不断更新的csv文件。我的任务是每秒阅读一次并更新图表。我试图查找ajax示例添加到d3中。但是bl.ocks.org没有我需要的东西。谁能告诉我一个好的ajax示例,我可以将其与我的应用程序集成。 - >接下来的任务是关闭csv并获得一个宁静的服务来读取数据。然后它将被解析并且图形将定期更新。 提前谢谢!
function handleClick() {
alert("Yaay! A Click Happened!");
}
// consider we have three .btn elements in DOM at this point
var btns = document.querySelectorAll('.btn'); // three elements are selected
btns.forEach(function(btn){
btn.addEventListener('click', handleClick); // here too, just three elements get the event listener attached to them
});
// now we create another .btn
var div = document.creatElement('div');
div.className = '.btn':
// we have never ever ever ever ... called .addEventListener on the last element so clicking it will have no effect at all.