javascript - User exist fucntion doesn't work when DB connection gets slow down -


i have below code check whether user exist or not in database. although it's working fine problem 1 db connection gets slow down returns user doesn't exist user exist in database. can please add "please wait.." option in code. user can wait until it's checks database.

when connection fast searches user , print correct information.

                    <script type="text/javascript">  var status_changed = "not set";  function check(value){  xmlhttp=getxmlhttpobject() var url="user_exist_function.jsp"; url=url+"?username="+value; xmlhttp.onreadystatechange=statechanged  xmlhttp.open("get",url,true) xmlhttp.send(null) } function statechanged(){  if(xmlhttp.readystate==4 || xmlhttp.readystate=="complete"){  var showdata = xmlhttp.responsetext;  if (showdata.includes("exist")) { document.getelementbyid("large").style.color = "green"; document.getelementbyid("large").innerhtml= ""; } else {   document.getelementbyid("large").innerhtml= ""; }    status_changed = showdata;  }  } function getxmlhttpobject(){ var xmlhttp=null; try{ xmlhttp=new xmlhttprequest(); } catch (e) { try { xmlhttp=new activexobject("msxml2.xmlhttp"); } catch (e){ xmlhttp=new activexobject("microsoft.xmlhttp"); } } return xmlhttp; }  function check_user() {        var local_status_changed = "not set";     local_status_changed = status_changed.replace(/(\n)/gm,"");      if (local_status_changed.includes("exist"))     {                 return true;     }     else     {         document.getelementbyid("large").innerhtml= "<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user doesn't exist in our database. please verify email id.</b>";           }     return false; }  </script>  <form action="edit_form_redirect.jsp" method="post" onsubmit="return check_user();">   <div style="background-color:#fa0536; overflow: auto;" class="large" id="large"></div>   <input class="text_email_1-css" placeholder="enter email id" name="email"  pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"  oninvalid="setcustomvalidity('please enter valid email id')" onkeyup="check(this.value);" size="30" required />         <input type="hidden" name="action" value=""/>         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" class="button-css" value="submit" /> </form> 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -