I am adding some form validation and updating the visibility of a notification depending on the status code of an http request using:
function isValidEndpoint()
{
var xmlHttp = null;
var myurl = "/restyendpoint/" + document.getElementById("endpoint").value;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", myurl, true );
xmlHttp.send( null );
if (xmlHttp.status == 409) {
document.getElementById("sucnot").style.visibility="hidden";
document.getElementById("warnot").style.visibility="visible";
} else {
document.getElementById("sucnot").style.visibility="visible";
document.getElementById("warnot").style.visibility="hidden";
}
}
When I load the page the elements are both invisible, on typing the first character I get the "That endpoints free" message (as the first character entered doesn't exist in the db). From that point the visibility of the notifications doesn't change, even though I can confirm correct request/response from the "restyendpoint" validation.