I have been following the answer found in this post. But it only works when passing a local URL, not any external ones.
How do I get it to work with external URLs?
I have the below basic site I have been using for testing.
<!doctype html>
<html lang="en">
<head>
<title>Test</title>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
function setGoogleToRed ( )
{
$('#google').removeClass('label-success').addClass('label-danger');
setTimeout ( "setGoogleToGreen()", 2000 );
}
function setGoogleToYellow ( )
{
$('#google').removeClass('label-success').addClass('label-warning');
setTimeout ( "setGoogleToGreen()", 2000 );
}
function setGoogleToGreen ( )
{
$('#google').removeClass('label-danger').addClass('label-success');
}
function checkurl ( )
{
var url = "blah";
$.ajax(url,
{
statusCode: {
200: function() {
setGoogleToGreen();
}
}, error: function () {
setGoogleToRed()
},
});
}
</script>
<style>
.label {
border: 1px solid #000;
}
.label-success {
background-color: #5cb85c;
}
.label-warning {
background-color: #f0ad4e;
}
.label-danger {
background-color: #d9534f;
}
</style>
</head>
<body>
<header>
<input type="button" value="Check URL" onclick="checkurl()"/>
<span id="google" class="label label-success" >google</span>
</header>
</body>
</html>