Post by iDunk on Sept 24, 2009 12:48:02 GMT -8
<SCRIPT TYPE="text/javascript">
function createRequestObject() {
var req = "";
var browserCatch;
if (window.XMLHttpRequest) {
// Firefox, Safari, Opera...
browserCatch = 1;
req = new XMLHttpRequest();
} else if(window.ActiveXObject) {
// Internet Explorer 5+
browserCatch = 2;
//req = new ActiveXObject("Microsoft.XMLHTTP");
req = new ActiveXObject("Msxml2.XMLHTTP");
} else {
alert('The AJAX auto-update is not compatible with this browser.');
}
document.write(browserCatch);
//document.getElementById('catch').innerHTML = browserCatch;
return req;
}
var obj = createRequestObject();
function requesthandle() {
//document.getElementById('rstate').innerHTML = obj.readyState + " " + obj.status;
if (obj.readyState == "4" || obj.status == "200") {
var response = "";
var response = obj.responseText;
if (response) {
var data = response.split('|');
var date = data[0];
var time = data[1];
var vms = data[2];
var status = eval(data[3]);
var ping = data[4];
document.getElementById('raw').innerHTML = data;
document.getElementById('date').innerHTML = date;
document.getElementById('time').innerHTML = time;
document.getElementById('vms').innerHTML = vms;
switch (status) {
case 0:
document.getElementById('status1').style.display='none';
document.getElementById('status2').style.display='none';
document.getElementById('status0').style.display = '';
break;
case 1:
document.getElementById('status0').style.display = 'none';
document.getElementById('status2').style.display = 'none';
document.getElementById('status1').style.display = '';
break;
case 2:
document.getElementById('status0').style.display = 'none';
document.getElementById('status1').style.display = 'none'
document.getElementById('status2').style.display = '';
break;
default:
alert('None!');
}
if (ping == 1) {
document.getElementById('offline').style.display = 'none';
document.getElementById('online').style.display = '';
}
else {
document.getElementById('online').style.display = 'none';
document.getElementById('offline').style.display = '';
}
}
}
date = new Date();
document.getElementById('graph').src="newsamplegraph.php?offset=1200&"+date.getTime();
document.getElementById('graph3').src="newsamplegraph.php?offset=600&"+date.getTime();
document.getElementById('graph2').src="newsamplegraph.php?offset=0&"+date.getTime();
}
function sendRequest() {
obj.open('get', 'data.php');
obj.onreadystatechange = requesthandle;
obj.send(null);
}
function update() {
sendRequest();
setTimeout("update()", 10000);
}
</SCRIPT>
What is wrong with this code!?! This code works in every single browser I've tried, except for Internet Explorer 8. For some reason it either throws an "unspecified error" or a "permission denied" error. If somebody could tell me what's going on here, I'd appreciate it much. Thank you.
Edit: Also, it may help to mention that it works the first time to fetch the data, but it doesn't refresh the data (other than the images). >.<
-iDunk