اولاً:
xmlhttp.open یه ورودی سوم هم داره که خیلی ربطی نداره.
دوماً:
شما باید چک کنی که readyStateش 4 باشه و statusش 200 باشه.
کد:
function getdata(){
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
xmlhttp = new
ActiveXObject('Microsoft.XMLHTTP'); } catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
if(xmlhttp){
var obj = document.getElementById(divid);
xmlhttp.open("GET", 'random.php', true);
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState==4) {
if(xmlhttp.status==200) {
obj.innerHTML = xmlhttp.responseText;
}
}
}
xmlhttp.send(null);
}
}