Introduction
There is an address book system deployed on several servers at the same time, but there is a link to the address book on the homepage, linked to this system. The problem is that sometimes the server pointed to by the link fails, so I hope that on this server In case of failure (service unavailable), links to other servers can be pointed to.
Solution 1: XMLHTTP solution
The following code is excerpted from meizz's reply in [2]:
Disadvantages: Use ActiveXObject, so it is IE Only. Non-IE core browsers are not available.
Solution 2: jQuery extension
For the following content, please refer to [1]
Home page: http:/ /plugins.jquery.com/project/linkchecker
Demo page: http://sidashin.ru/linkchecker/
The downloaded compressed package contains calling examples.
Supplement:
If you target a The specific URL, just using jQuery without a plug-in, can be like this:
$.ajax({
url: 'http://some.url.com',
type: 'GET',
complete: function(response) {
if(response. status == 200) {
alert('valid');
} else {
alert('invalid');
}
}
});
Reference documents:
[1]http://zhidao.baidu.com/question/138740329.html?push=ql
[2]http://topic.csdn. net/t/20041214/16/3644539.html
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn