readyState == 3 does not work

0

Good morning,

In my code everything works perfectly except the readyState == 3, it is assumed that in that state the information is being sent to the .php and it should show me the 'loading ...' in the div, lower when it is in state 4 and answer 200 if I show the result in the div,

How could I solve the status 3?

Thank you!

function consultar_solicitudes(str){

  if (str==""){
   //borro el div por si hay algo en el 
    document.getElementById("div_para_tabla").innerHTML="";
    return;
  }
  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else { // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
    if (this.readyState==3)
    {
//aqui dentro del if no me funciona esto
      document.getElementById("div_para_tabla").innerHTML="Cargando...";
    }

    if (this.readyState==4 && this.status==200)
{
// aqui funciona perfectamente
      document.getElementById("div_para_tabla").innerHTML=this.responseText;
    }
  }
  xmlhttp.open("GET","../PHP/consultar_solicitudes.php?q="+str,true);
  xmlhttp.send();
}
    
asked by Gabriel Uribe Gomez 08.05.2018 в 01:21
source

0 answers