onreadystatechange() gets called 3 times. the second time 'results-div'.innerhtml is set to 'empty' and then erased on the last call to the function. also, does jquery handle ajax browser compatibility?
function loaddata(){
var res = new XMLHttpRequest();
res.onreadystatechange=function(){
alert('change'); //for debug
if(res.readyState == 4 && res.status==200){
document.getElementById('results-div').innerHTML = res.response;
}
else{
alert('nothing'); //for debug
document.getElementById('results-div').innerHTML = '<p> empty </p>';
}
}
res.open('GET', '?search=' + value);
res.send();
}
'results-div'.innerHTML erased on the last call. if(must be true) 'results'.innerHTML = res.response = ''