473,505 Members | 13,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

My ping script get error or sth

1 New Member
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]
Nov 25 '07 #1
1 1948
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

You're using document.write after the page has loaded.

Either set the innerHTML of an element on the page or dynamically create these elements and append them to the body or another element.
Nov 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
5646
by: Alexandre Plennevaux | last post by:
hello ! I would like to measure the time a user needs to connect to my website. In other words, to perform a ping between my website and the user's computer. I'm scratching my head as to how...
17
18179
by: wana | last post by:
I was reading through original source code of ping for some insight and was confused by unusual code. Entire listing available at: http://www.ping127001.com/pingpage/ping.html #include...
0
7750
by: Ed | last post by:
I've attached some VB.NET code I've hacked together (some taken from MS examples & newsgroup postings) that will perform a ping or IcmpSendEcho using the icmp.dll (see this for more info:...
5
5569
by: Deepak | last post by:
I am programing a ping application which pings various centers . I used timer loop and it pings one by one. Now when i finish pinging one center it should wait for the ping_completed function to...
1
18436
by: Krish | last post by:
All, I have an offline application that works online for some data syncronization. For data syncronization I access a webservice. I want to show whether my application is online or not by checking...
3
1826
by: amaccormack | last post by:
I wrote a quick script to check the "up-ness" of a list of machines, and timeout after 1 second. However, with a lot of timeouts, the script takes a logn time, so I thought to parallelise it....
3
8352
by: imughal | last post by:
I got the perl script which does following task. This solution reads in a line from a text file that is passed in as input parameter 1 to a Perl script. This script will then ping the machine...
2
1743
by: airwot4 | last post by:
I've been using ADSI to lookup a complete hostname from active directory from a partial as part of a script. It goes something like: Retrieve partial hostname from excel spreadsheet -...
6
3446
by: Dave Marden | last post by:
I currently use this routine in vbscript to ping computers and get the status of ping to determine whether to try to backup a machine, I am trying to change it to work with vb2003.net I am...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.