[JavaScript] checks (determines) whether a link (URL) is valid (the service is available)

Source: Internet
Author: User
How can I use javascript to determine whether the requested url/link is valid (connectable and available )? Introduction There is an address book system deployed on several servers at the same time, but there is a Address Book link on the home page to link to this system. the problem is that sometimes the link to the server fails, so I hope... syntaxHighlighter. all ();

How can I use javascript to determine whether the requested url/link is valid (connectable and available )?

Introduction

There is an address book system deployed on several servers at the same time, but there is a Address Book link on the home page to link to this system. the problem is that sometimes the link points to a server with a failure, so you want to point to other servers when the server is faulty (the service is unavailable.

Solution 1: XMLHTTP

The following code is taken from the reply of meizz in [2:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.