may i know what's wrong with my code? it keep return me 0 no matter the url links is available or not.
<Script>
function doSomethingIfFound(url, status) {
alert(url + " was found, status " + status);
}
function doSomethingIfNotFound(url, status) {
alert(url + " was not found, status " + status);
}
function test(url) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
doSomethingIfFound(url, xhttp.status);
} else if (xhttp.readyState == 4 && xhttp.status != 200) {
doSomethingIfNotFound(url, xhttp.status);
}
};
xhttp.open("GET", url, true);
xhttp.send();
}
test("https://test.e-cover.com.my/");
test("https://www.e-cover.com.my/");
test("http://www.mypolicy.com.my/mypolicy/login.jsp/");
test("https://itdidnotexistwhenitrieitiswear.museum/");
</script>