Hello Everyone,
I have a "small" problem with java. :-)
I made a Php - Javascipt for displaying the status of my servers.
The Xml response and the php scipt are working fine.
But the Javascipt doesn't do what i want it to do.
I Have 2 Divs in my html (id="result1" and id id="result2"), but my javascipt is overwriting the result from "result1" with the one from "result 2".
Firebug is also showing 2 ajax requests and resonses, but i am only seeing 1 of them on my screen. (Without any Errors in firebug).
Demo => http://a000008.pixelstudio.eu.com/index.php?pid=3
Html Source code => Go to demo (View source)
Javascript Source =>
//LOAD xmlHttp method.
var xmlHttp;
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
//PARSE DATA
function setmessage(value,org) {
var messageArea = document.getElementById(org + "result");
var fontcolor = "red";
if ( value == 1 ) {
var fontcolor = "green";
var msg = "ONLINE";
} else {
var fontcolor = "red";
var msg = value;
}
messageArea.innerHTML = "<font color=" + fontcolor + ">" + msg + "</font>";
}
//RECIEVE DATA TRUE XML
function callback() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var value = xmlHttp.responseXML.getElementsByTagName("msg")[0].firstChild.data;
var org = xmlHttp.responseXML.getElementsByTagName("org")[0].firstChild.data;
setmessage(value,org);
}
}
}
//PUSH DATA
function ping_service(value) {
createXMLHttpRequest();
var data = "update.php?id=" + escape(value);
xmlHttp.open("GET", data, true);
xmlHttp.onreadystatechange = callback;
xmlHttp.send(null);
}
What am i doing wrong ?
Thanks Ilias
Ps: Sorry for my English (Dutch speaking)