Update 'public/js/domain_check.js'
This commit is contained in:
parent
34250dc8df
commit
26b4e6c40f
|
@ -1,23 +1,20 @@
|
|||
function updateAvailability() {
|
||||
if (this.responseText === "y") {
|
||||
document.getElementById("avail").innerHTML = "Available!";
|
||||
} else {
|
||||
document.getElementById("avail").innerHTML = "Not available";
|
||||
}
|
||||
}
|
||||
|
||||
function checkAvailability() {
|
||||
var name = document.getElementById("name").value;
|
||||
|
||||
if (name === "") {
|
||||
document.getElementById("avail").innerHTML = "";
|
||||
return
|
||||
let name = document.getElementById('name').value;
|
||||
if (name === '') {
|
||||
document.getElementById('avail').innerHTML = '';
|
||||
return false;
|
||||
}
|
||||
|
||||
document.getElementById("avail").innerHTML = "Checking availability...";
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
req.addEventListener("load", updateAvailability);
|
||||
req.open("GET", "/api/check_availability?name="+encodeURIComponent(name));
|
||||
req.send();
|
||||
}
|
||||
document.getElementById('avail').innerHTML = 'Checking availability...';
|
||||
fetch('/api/check_availability?name=' + encodeURIComponent(name), {
|
||||
method: 'GET',
|
||||
mode: 'cors'
|
||||
}).then(g => g.text()).then(g => {
|
||||
if (g === 'y') {
|
||||
document.getElementById('avail').innerHTML = 'Available!';
|
||||
} else {
|
||||
document.getElementById('avail').innerHTML = 'Not available';
|
||||
}
|
||||
}).catch((e) => {
|
||||
document.getElementById('avail').innerHTML = 'Not available';
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue