title: Error when attempting to check if page exists or not (function returns undefined)
body: <p>I am attempting to check if a URL exists or not. The function is supposed to return true if the url is not 404, and false if it is 404'd.</p>
  
  <p>Now for some reason this function is returning "undefined"</p>
  
  <p>Here is my code:</p>
  
  <pre><code>function checkURL(url){
      var xmlhttp; // initialize the request object
      // All the browsers except for the old IE
      if (window.XMLHttpRequest) {
          xmlhttp = new XMLHttpRequest();
      } else {
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //old IE
      }
      if (xmlhttp) {
          xmlhttp.open("HEAD", url, true);
          xmlhttp.onreadystatechange=function() {
              if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status!=404) {
                  return true;
              } else {
                  return false;
              }
          }
          xmlhttp.send(null);
      }
  }
  </code></pre>
  
  <p>Thanks in advance. Cheers.</p>