473,327 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Check host availability

Hello

I'm trying to write a javascript that checks if a server/host is
available. To be more precice. I would like to check if the browser can
read an XML file from a server. If not the script should read the same
XML file from a backup server.

Does anyone have any idea how to achive that??

Any help is appreciated.

Thanks

Andy

Dec 5 '06 #1
6 3643
te******@gmx.net wrote:
Hello

I'm trying to write a javascript that checks if a server/host is
available. To be more precice. I would like to check if the browser can
read an XML file from a server. If not the script should read the same
XML file from a backup server.

Does anyone have any idea how to achive that??

Any help is appreciated.

Thanks

Andy
Hi,

You could use an Ajaxoid approach.
Try a httpxmlrequest-like thing, and check for errors when it returns.
for starters: www.w3schools.com, and select Ajax.

However, I think a serverside approach (eg PHP) would be easier if that is
an option for you.

Regards,
Erwin Moller
Dec 5 '06 #2
te******@gmx.net wrote:
Hello

I'm trying to write a javascript that checks if a server/host is
available. To be more precice. I would like to check if the browser can
read an XML file from a server. If not the script should read the same
XML file from a backup server.
Well first, that server/host is going to have to be in the same domain
as the web page itself. If you can get the web page you should be able
to get the data right? If you're thinking of having a webpage on
"mydomain.com" and wanting it to check/pull data from
"overtherainbow.org" it isn't going to happen, the browser security
model will not allow that to happen.

However if your web page is www.mydomain.com and www.mydomain.com/data/
is mapped to a different server then there are several possibilities.

The best approach is to have your web server monitor the status of your
data server since it's on the same network and has access to network
tools far more advanced than the browser will give you. Here it's a
simple task to have the browser do an ajax request to the web server and
get the status of the data server transmitted back.

If you need the browser to do the check then things are slightly more
sticky. You'll need to use ajax again to call the data server and then
check the response codes. You'll get nearly instant replies if the
data server is up but refusing connections, but if the server is down it
will take a very long time for the ajax request to time out and throw an
error.

In either case you will be using ajax, just do a search on "ajax
tutorial" on google and you'll find a few good ones.

---------------------------------------------------------------------------
http://www.hunlock.com
$FA
Dec 5 '06 #3
te******@gmx.net wrote in news:1165325811.699898.88490@
79g2000cws.googlegroups.com:
I'm trying to write a javascript that checks if a server/host is
available. To be more precice. I would like to check if the browser can
read an XML file from a server.
It is easy to check if a GIF file can be served up [1]. If you use the same
server for both, then you can *probably* assume that if the server is up
for GIFs, it is also up for any other files it is hosting.

[1] Use the "onLoad" and "onError" methods of the image object.
Dec 6 '06 #4

Mike.Duffy schrieb:
te******@gmx.net wrote in news:1165325811.699898.88490@
79g2000cws.googlegroups.com:
I'm trying to write a javascript that checks if a server/host is
available. To be more precice. I would like to check if the browser can
read an XML file from a server.

It is easy to check if a GIF file can be served up [1]. If you use the same
server for both, then you can *probably* assume that if the server is up
for GIFs, it is also up for any other files it is hosting.

[1] Use the "onLoad" and "onError" methods of the image object.

Thank you very much guys. Your hints were very helpful. I finally
decided for the image solution. very easy indeed and exactly what I
needed...

var myServer = "";
var picServerOne = new Image();
var picServerTwo = new Image();
picServerOne.src =
"http://xxxxxxx.awardspace.com/map/test.gif";
picServerTwo.src = "http://xxxxxxx.50webs.com/map/test.gif";
if (picServerTwo.complete){myServer = "50webs";} // Backup
server
if (picServerOne.complete){myServer = "awardspace";} // Main
server

Dec 7 '06 #5
te******@gmx.net wrote:

[...]

You might need to search for a way to prevent the image from getting cached.
Dec 7 '06 #6
te******@gmx.net wrote:
var myServer = "";
var picServerOne = new Image();
var picServerTwo = new Image();
picServerOne.src =
"http://xxxxxxx.awardspace.com/map/test.gif";
picServerTwo.src = "http://xxxxxxx.50webs.com/map/test.gif";
if (picServerTwo.complete){myServer = "50webs";} // Backup
server
if (picServerOne.complete){myServer = "awardspace";} // Main
server
Since `complete' is an undocumented proprietary property that does not need
to be supported, myServer will always hold the empty string in other UAs
(e.g. IE). Use the also proprietary, but documented `onload' and `onerror'
event handlers of Image objects instead.
PointedEars
--
When the power of love overcomes the love
of power, the world will know peace.
-- Jimi Hendrix
Dec 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jay | last post by:
Hi ! I am a beginner in PHP. Does anybody know how to check if an URL is alive or dead in PHP (not exist or server down...or whatever ) ? Any help would be appreciated ! Thanks ! Jay
3
by: deko | last post by:
I use #currentlink in a nav list of links to indicate which page is currently being viewed. The code in the nav list looks like this: <p><a href="index.php">Home Page</a></p> <p><a...
9
by: Dan Williams | last post by:
Can anyone tell me how to go about creating my own custom ASP page that can show several different peoples availability from their Outlook/Exchange 2000 calendars? I don't want to have to ask...
10
by: trint | last post by:
Recently the host for our website has been going down for unknown reasons like three or four times a week, which obviously means that we are loosing business during the down time. Any one know...
5
by: Puja | last post by:
Hi all, I need to check domain name availibility on one of my page in website. I do not want to let user click a link which leads to sites which check for domain name but I want check on my...
1
by: keri | last post by:
Hi, posting again with a more specific question. I am trying to create a query that checks the availability of a unit based on TBLUNITS and TBLBOOKINGS. I figured I could run a query to show...
1
by: polycom | last post by:
Hi, I am coding a mysql health check script. The logic is to execute the commands (only once)show status,show slave status,show variables and fetch the variable name and value in a hash refer or...
3
by: nRk | last post by:
Hi, Is there any way to check the availability of a web service without including any extra web method? Thank & regards nRk
2
by: deepika1 | last post by:
hi , i wrote a code for to delete the particular rows in a table using check boxes.But in that i select the particular rows and click on the delete button these rows didn't delete.plz check...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.