var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if(this.readyState == 4 && this.status == 200) { document.getElementById("xhr").innerHTML = ''; } }; xhr.open("GET", "xhrdata.php?val=1&ext=0" ,true); xhr.send(null);