A
A
Anton2019-02-17 20:57:56
AJAX
Anton, 2019-02-17 20:57:56

Why doesn't readyState fire over https?

function Auth(){
  
  div_status = document.getElementById('status_auth');
  login = document.getElementById('login');
  pass = document.getElementById('pass');
  
  div_status.innerHTML = '';
  
  if( login.value != ''){
    
    if( pass.value != '' ){
      
      xhr = new XMLHttpRequest();
            
      xhr.open("POST","ajax/login.php",true);
      
      xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

      xhr.send("login="+login.value+"&pass="+pass.value);
      
      if( xhr.readyState != 4 ){
        
        div_status.innerHTML = 'Подождите пожалуйста';
        
      } 
      
        xhr.onreadystatechange = function() {
  
          if( xhr.statusText == 'OK' ){
            
            console.log(xhr);
            
            json_data = JSON.parse(xhr.responseText);
            
            div_status.innerHTML = json_data.statusx;
        
          }
        
        }
      
    }else div_status.innerHTML = 'Введите пароль!';
    
  }else div_status.innerHTML = 'Введите логин!';
  
}

What could be the problem, through http readyState works as it should, and through https readyState returns xhr.readyState != 4

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question