Out of curiosity, what results do you get with the following attempts?
Code: Select all
xhr.onloadend = function(){
document.getElementById('dst').textContent = xhr.response + (num++);
xhr = null; // <-- deleting the reference to the XHR object
setTimeout(onTimer, 1000);
};
Code: Select all
xhr.onloadend = function(){
document.getElementById('dst').textContent = xhr.response + (num++);
xhr.onloadend = null; // <-- deleting the event listener, which contains a reference to the XHR object
setTimeout(onTimer, 1000);
};
Code: Select all
xhr.onloadend = function(){
document.getElementById('dst').textContent = xhr.response + (num++);
xhr.onloadend = null; // <-- combining the 2 previous codes. first, deleting the event listener...
xhr = null; // <-- ... then the reference to the XHR object
setTimeout(onTimer, 1000);
};
Code: Select all
xhr.onloadend = function(){
document.getElementById('dst').textContent = 'DUMMY' + (num++); // removing reference to the XHR object in the event listener
setTimeout(onTimer, 1000);
};