I am trying to check if a website is up and forward it to an error page if it's not. So far I tried doing this but it goes to error page. I checked if website was up and it is. What am I doing wrong? I am trying to send header using jQuery ajax call.
function checkpageus(){
$.ajax({
type: 'HEAD',
timeout: 1000,
url:"www.prioritymeter.net",
statusCode:{
400: function(response){
window.location = "www.prioritymeter.com/static_pages/error.html";
},
200: function(response){
window.location = "https://www.prioritymeter.net/wb/b/us.xhtml";
}
}
});
}
<a onclick="checkpageus()" style="cursor:pointer">My Account</a>