var oldip = document.getElementById('ip').value;
var newip1 = document.getElementById('txtintip1').value;
var newip2 = document.getElementById('txtintip2').value;
var newip3 = document.getElementById('txtintip3').value;
var newip4 = document.getElementById('txtintip4').value;
var newip = newip1 + "." + newip2 + "." + newip3 + "." + newip4;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
if (xmlhttp.responseText == "pinging") {
alert("IP is already in use");
}
}
}
xmlhttp.open("GET", "checkping.php?ip=" +newip, true);
xmlhttp.send();
if (document.getElementById('interface').value == "default") {
alert("Select Interface");
document.registerlist.interface.focus();
return false;
}
if (document.getElementById('txtintip1').value === "") {
alert("Enter Valid IP Address");
document.registerlist.txtintip1.focus();
return false;
}
if (document.getElementById('txtintip2').value === "") {
alert("Enter Valid IP Address");
document.registerlist.txtintip2.focus();
return false;
}
if (document.getElementById('txtintip3').value === "") {
alert("Enter Valid IP Address");
document.registerlist.txtintip3.focus();
return false;
}
if (document.getElementById('txtintip4').value === "") {
alert("Enter Valid IP Address");
document.registerlist.txtintip4.focus();
return false;
}
Above is my code in which first ajax will retrieve whether given ip is conflicting or not. But I face a problem that the ajax is responding slow and javascript is complete. So I am not able to complete my action so how to run first ajax and then javascript execution will continue?