Javascript only works with the IE Bugger

Asked

Viewed 409 times

-1

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

Follow an excerpt from my JS:

<script src="http://code.jquery.com/jquery-latest.js"></script>
function login(){

var checkCpf = 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 ='';

}

};
  • 4

    Is this all your code? Usually this is caused by a call to console.log in the code, but in what you posted...

  • Already tried to replace the jquery-latest.js by a stable version, which has been proven to work with your version of IE?

  • I managed to solve the problem! @bfavaretto exactly, everything I found talked about the console.log, but as you noted, I didn’t touch it. @mgibsonbr I’ve changed, thanks for the tip, but that’s not what solved the problem! The problem is that my ID form was the same name as the JS function! I just couldn’t figure out what the relationship was with the IE Developer Tools. Thanks for your attention!

  • @Nod The ideal is that you answer your own question with what solved the problem and mark it as the correct answer.

1 answer

0


I solved, the problem was that I had a form and its id was equal to the name of my javascript function. For example:

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

And in my Javascript:

function login(){
    ...
}

I could not find out what the relationship this has 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!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.