0

I have this jquery script for showing a div on server response

function valLogin(){
    //testing regular expression
    var var1 = $("#username").val();
    var var2 = $("#password").val();

     $.ajax({ //Make the Ajax Request
     type: "POST",
     url: "login.php", //file name
     data: "username="+var1+"&password="+var2, //data
     success: function(server_response){

    $("#logform").ajaxComplete(function(event, request){
       if (server_response == 1){
        window.location.reload();
        return false
      } else if (server_response == 0){
            $('#logmess').show;
        return false
      }
    }); //ajaxcomplete
     }
    }); //$.ajax
}

<div id="logmess" style="display:none;" align="right">Wrong UserID or password!&nbsp;<img src="/img/close.gif" onClick="$('#logmess').hide();" style="cursor:pointer;"/></div>

if server_response==0 then I show the div. I have a close button inside div with onClick="$('#logmess').hide();". the div is hiding but is appearing again after few seconds and this happens again and again. why the div is appearing again? Is something in my script that makes a loop?

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159

0 Answers0