I have a button in login form popup modal <button type="submit" class="btn btn-primary btn-lg btn-block" onclick="checkall();">Login</button>
function checkall()
    {
     var name=document.getElementById( "login_username" ).value;
     var pass=document.getElementById( "login_password" ).value;
      var testing = true;
     if(name)
     {
      $.ajax({
      type: 'post',
      url: 'checkuser.php',
      data: {
       user_name:name,
       user_pass:pass,
      },
      success: function (response) {
       $( '#name_status' ).html(response);
       if(response=="OK") 
       {   
          var getUrl = window.location;
          var baseUrl = getUrl .protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1];
          var base2 = baseUrl + "/instructor/index.php";
          window.location = base2;          
       }
       else
       {        
        $('#text-login-msg').text("Testing");
          testing = false;
       }
      },
      error: function() {
        $( '#name_status' ).html("");
        return false;
      }
      });      
     return testing; 
     }         
  }
Everything is work I just want to stop the form model to refresh the page and show error on screen if details don't match.
`
 else
       {        
        $('#text-login-msg').text("Testing");
          testing = false;
       }
`
It is supposed to show testing and leave the popup open. But this is not working. I have tried return false also but same problem. I know ajax is async any way around that so that if data don't match then it should stay like that without refreshing page.
Thank you.
 
     
    