0

Is there a common way to detect whether a web service is accessible, through javascript? For example, if the web server is down or IIS on it is stopped, I can stop the program.

1 Answer 1

1

You can simply use jQuery's AJAX function to send a request to the server, and listen for errors (i.e.: timeout)

var request = $.ajax({
  url: "http://somewebsite.com",
  type: "POST"
});

request.done(function(msg) {
  $("#log").html("Website is up.");
});

request.fail(function(jqXHR, status) {
  $("#log").html("Website is down.");
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.