hi there since i am trying to code a java script for ping several server in the same page and resulting in picture of red/blue strip. Btw: i got stuck with some code that is not working ....it is the below code
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<input type=button value=ping onclick=doping()><BR>
<input type=button value=ping2 onclick=doping2()>
<script>
probeurl="http://www.xxx.com";
function doping()
{
dt = new Date();
// callback function to be executed and request is complete
callback = function() {
ndt = new Date();
time = (ndt-dt)/1000+"ms";
if (obj.readyState == 4) {
if (obj.status == 200) {
alert(time);
alert(obj.responseText);
document.write("<input type=button value=ping onclick=doping();>");
document.write("<img src='blue.jpg'width='81' height='8'>");
document.write("<input type=button value=ping2 onclick=doping2();>");
} else {
alert('There was a problem with the request.');
document.write("<input type=button value=ping onclick=doping();>");
document.write("<img src='red.jpg'width='81' height='8'>");
document.write("<input type=button value=ping2 onclick=doping2();>");
}
}
}
if(window.XMLHttpRequest)
{
obj = new XMLHttpRequest();
obj.open("GET", probeurl, true);
}
else if(window.ActiveXObject)
{
obj = new ActiveXObject("Microsoft.XMLHTTP");
obj.open("GET", probeurl+"?aaa=333", true);
}
// specify callback function
obj.onreadystatechange = callback;
obj.send(null);
}
function doping2()
{
dt = new Date();
if(window.XMLHttpRequest)
{
obj = new XMLHttpRequest();
obj.open("GET", probeurl+"?aaa=333", true);
obj.send(null);
}
else if(window.ActiveXObject)
{
obj = new ActiveXObject("Microsoft.XMLHTTP");
obj.open("GET", probeurl+"?aaa=333", true);
obj.send(null);
}
ndt = new Date();
time = (ndt-dt)/1000+"ms";
alert(time);
}
</script>
</BODY>
</HTML>[/HTML]