title: Displaying with <a onclick> in Javascript (AJAX)
body: <p>Hello i have an issue with this code that it's turning me mad (i'm a rookie in terms of JS language):</p>
  
  <pre><code>function procesarCambio(){
      if(obj.readyState == 4){
              if(obj.status == 200){
                  document.getElementById("miDiv").innerHTML = obj.responseText;
                  var persona;
                  if(window.JSON)
                      persona = window.JSON.parse(obj.responseText);
                  else
                      persona = eval( '(' + obj.responseText + ')' );
                  if(window.sessionStorage){
                      sessionStorage.setItem("clave", persona.CLAVE);
                      sessionStorage.setItem("login", persona.LOGIN);
                      sessionStorage.setItem("nombre", persona.NOMBRE);
                      sessionStorage.setItem("email", persona.EMAIL);
                      sessionStorage.setItem("ultAcceso", persona.ULTIMO_ACCESO);
                      sessionStorage.setItem("foto", persona.FOTO);
                  }
                  //alert("Bienvenido" + sessionStorage.getItem("nombre")); //No tiene que ser un alert
                  //setTimeout(window.location = "index.html", 0);
                  document.getElementById("error").style.opacity = '0';
                  document.getElementById("acierto").style.opacity = '1';
              }else{
              //alert("Nombre de usuario o contrase&amp;ntilde;a incorrectos");//No tiene que ser un alert
              document.getElementById("acierto").style.opacity = '0';
              document.getElementById("error").style.opacity = '1';
              }
          }
  }
  function ocultar(){
      document.getElementById("error").style.opacity = '0';
      document.getElementById("login").focus();
      return false;
  }
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div id="acierto" class="popup acierto"&gt;
              &lt;p&gt;Welcome&lt;/p&gt;&lt;a href="index.html"&gt;&lt;img src="imagenes/x.png" height="32" width="32"&gt;&lt;/a&gt;
              &lt;/div&gt;
          &lt;div id="error" class="popup error"&gt;
              &lt;p&gt;Error&lt;/p&gt;&lt;a href="#" onclick="ocultar(); return false;"&gt;&lt;img src="imagenes/x.png" height="32" width="32"&gt;&lt;/a&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>It handle the AJAX login request and then writes a message that can be both succesfull and error depending if the login gone right or not.
  It's all ok except for the fact that when i click on the X in the right corner of the success message, it calls the error function instead of go to index.html</p>