I tried this to reload the page without refreshing [AJAX...], but doesnt seem to be working :/
function refresh() {
link = document.location;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementsByTagName('table').innerHTML=xmlHttp.responseText;
}
}
xmlhttp.open("GET",link,true);
xmlhttp.send();
}
Anyone know what's wrong?
Don't use innerHTML, it's a proprietary Microsoft Jscript method that doesn't properly register the DOM. In example if you use it to import an element with an ID it's less akin to putting a crown on a queen's head and more akin to dumping bodies by a bridge, the may or may not have seen it, likely not. Stick to using importantNode with AJAX and your AJAX loaded content will work reliably. Also code is not text, do not use responseText, use responseXML. Then instead of having to re-request the same content you can simply unhide the layer that is already in the DOM unless you expect the content to have been updated in the past X number of seconds in which case you can delete the element and redo the AJAX request. See my video for a visual demonstration...