Check if URL Exists
Question from Instagram
by apasaja
JavaScript
var MrChecker = new XMLHttpRequest(),
CheckThisUrl = "//ru3aj.6wvp4yrh6.com/?oId=58&fr=9&qstype=2";
// Opens the file and specifies the method (get)
// Asynchronous is true
MrChecker.open('get', CheckThisUrl, true);
//check each time the ready state changes
//to see if the object is ready
MrChecker.onreadystatechange = checkReadyState;
function checkReadyState() {
if (MrChecker.readyState === 4) {
//check to see whether request for the file failed or succeeded
if ((MrChecker.status == 200) || (MrChecker.status == 0)) {
alert(CheckThisUrl + ' exist');
}
else {
alert(CheckThisUrl + ' not exists');
return;
}
}
}
MrChecker.send(null);