• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JavaScript: Check Server Status

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a little javascript file that connects to my server & downloads another file. Basically, what I want to do is write a small script that deals with the possibility of the server being down. It will check the server's url, if it is found then it will continue there, if it is not found it will try a different server.

I can't find anything on the web for a function to manage this. If anyone knows a function that will do it, i'd appreciate it.

Thanks a million,
Celine
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you were going to use a file on your local server and see if it existed, you could have used XMLHttpRequest object, but since it is on another server, you would get security errors.

So the way I would do it is with an image on that server

<img src="yourUrl/theImage.jpg" style="width:0;height:0;visiblity:hidden;position:absolute;" onerror="functionError()">

Eric
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you give me a full example of this, i'm not that good at this kind of thing. As in the whole html source of that page

Many thanks,
mikemm
[ May 08, 2005: Message edited by: mike mm ]
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whole source for what one of the two?
 
mike mm
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from your post please
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is two answers, the onerror solution and the xmlhttprequest solution...

which one?
 
mike mm
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh the onError one
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you looking for something like this?



Eric
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Eric

Whats the way u can do that with XML HttpRequest ?? I know how to send a request , but how to check whether there is any return value or not so that i can get to know if server is running ??
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code here where we look for a page by using a username and password checks to see if a page is available, but you can not check accross domains without changing the security setings for the site.

http://radio.javaranch.com/pascarello/2005/06/24/1119626686861.html

Eric
 
reply
    Bookmark Topic Watch Topic
  • New Topic