我不明白为什么这个小提琴会抛出
未捕获的错误:InvalidStateError:DOM 异常 11
function url(){
return '/echo/js/?js=' + 5 + Math.floor(Math.random()*900);
}
function poll(done){
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.status === 200 && xhr.readyState === 4){
var foo = xhr.responseText;
done(parseInt(foo));
}
};
xhr.open('get',url(),false);
xhr.send(null);
}
var button = document.querySelector('#poller');
var price = document.querySelector('#price');
button.addEventListener('click', function(){
poll(function(data){
price.innerText = data;
});
},false);