Div error with ajax

0

What happens is that when sending the form, if there is an error, a message is displayed in a div, this only happens the first time, then I keep pressing the submit, but I do not see the error message.

ajax function:

function login(){
    login.submit();
}

function ValidarRequeridos(){

divResultado        = document.getElementById("resultado");
var Usuario         = document.getElementById("Usuario").value;
var Password        = document.getElementById("Password").value;
ajax = newAjax();   


ajax.open("POST", "login_verify.php",true);
ajax.onreadystatechange=function() {
    if (ajax.readyState==4) {
        //mostrar resultados en esta capa
  divResultado.innerHTML = ajax.responseText;
  $("#resultado").delay(2000).hide(300);


}
}
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
//enviando los valores
ajax.send("Usuario="+Usuario+"&Password="+Password);    


};
    
asked by alexi gallegos 02.12.2017 в 21:08
source

1 answer

0

The problem is that after showing the message the first time you hide the div #resultado , but in no time you show it again.

That's why when the error occurs again, you change the content of the div assigning it to the property innerHTML but at no time indicate that the div should be displayed.

You should use the show method for it:

    //mostrar resultados en esta capa
divResultado.innerHTML = ajax.responseText;
$("#resultado").show();
$("#resultado").delay(2000).hide(300);
    
answered by 02.12.2017 / 21:19
source