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