JavaScript only works with IE debugger

-1

Hello. I have a code in JS that works perfectly in other browsers, however, IE only works with debugger (F12) enabled.

Here is an excerpt from my JS:

<script src="http://code.jquery.com/jquery-latest.js"></script>functionlogin(){varcheckCpf=document.getElementById("cpf").value;
var checkPass = document.getElementById("pass").value;
if(checkCpf == '' || checkPass == ''){
document.getElementById("confirmacao").innerHTML="<p>Você precisa informar seu CPF e sua senha para entrar!</p>";
document.getElementById("cpf").value = '';
document.getElementById("pass").value = '';
document.getElementById("cpf").focus();
}else{
    if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
    }else{
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }  
    xmlhttp.onreadystatechange=function(){
        if(xmlhttp.readyState==4 && xmlhttp.status==200){       
            var callback = xmlhttp.responseText;

            if(callback !=0)
               window.location.replace(callback);
            else{
               document.getElementById("confirmacao").innerHTML="<p>CPF e/ou senha inválidos!</p>";
            }
        }
   }

var params = $('form#login').serialize();

xmlhttp.open("POST","valida.php",false); 
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send(params);

document.getElementById("cpf").value ='';
document.getElementById("pass").value ='';

}

};
    
asked by anonymous 16.05.2014 / 22:30

1 answer

0

I decided, the problem was that I had a form and its id was the same as the name of my javascript function. For example:

<form id="login" onsubmit="login()"> 
    ...
<\form>

And in my JavaScript:

function login(){
    ...
}

I was not able to find out what the interface is with the Developer Tools (F12) of Internet Explorer since when it was enabled the page did not present errors, but after changing the ID of my form, everything worked perfectly! p>     

21.05.2014 / 04:45