title: Javascript breaking after an if statement
body: <p>I can't figure out why everything inside the request.onreadystate function up to the comment works but the following alert()'s do not. The script seems to break after the if statement.</p>
  
  <p>I'd really appreciate someone looking at my code for me. Thanks a lot.</p>
  
  <pre><code>    function positionHandler(position) {
          if (!document.getElementById("span")) document.body.appendChild(document.createElement("span"));            
          document.getElementsByTagName("span")[0].innerHTML = "("+position.coords.latitude+","+position.coords.longitude+")";
          request = new XMLHttpRequest();
          request.asycnc = false;
          request.open('GET','get.php?latitude='+position.coords.latitude+'&amp;longitude='+position.coords.longitude);
          request.onreadystatechange = function() {
              if (request.readyState != 4) return false;
              else if (request.readyState == 4 &amp;&amp; request.status == 200) {
                  var results = request.responseXML.getElementsByTagName('note');
                  for (var i in results) {
                      if (!document.getElementById(results[i].getAttribute('id'))) {
                          var note = document.createElement('div');
                          note.innerHTML = results[i].childNodes[2].childNodes[0].nodeValue;
                          note.id = results[i].getAttribute('id');
                          document.getElementById('main').appendChild(note);
                          //everything up until this point works
                      }
                  }
                  alert("this doesn't work 1");
              }
              alert("this doesn't work 2");
          }
          request.send(null);
          alert("this does work!");
      }
  
      var position = navigator.geolocation.watchPosition(positionHandler);
  </code></pre>