title: javascript/jQuery setTimeout and clearTimeout not working
body: <p>This is a total noob problem. Sorry. I am using jQuery and ajax with php backend to check availability of usernames on keyup. I have this in my form.</p>
  
  <pre><code>Username &lt;input id="uName" type="text" maxlength="20" name="username" /&gt;&lt;br /&gt;
  &lt;span id="uNMessage"&gt;&amp;nbsp;&lt;/span&gt;
  </code></pre>
  
  <p>and this in my script</p>
  
  <pre><code>function unchk(){
      $('#uName').keyup(function(){
          var ab = $(this);
          if(ab.val().length &gt; 4){
              $.ajax({url: "/php/username-check.php",type:'post',data:{username:$(this).val()},
                  success: function(result){
                      if(result == 0){
                          ab.css("outline-color","red");
                          untmr('Username Already Taken');
                      }   
                      else if(result == 1){
                          ab.css("outline-color","#42c43b");
                          $('#uNMessage').html('&amp;nbsp;');
                      }               
                  }
              });
          }
          else{
              $(this).css("outline-color","red");
          }
      });
  }//END FUNCTION UNCHK
  function untmr(msg){
      clearTimeout(unto);
      unto = setTimeout(unmsg(msg),1500);
  }
  function unmsg(msg){
      $('#uNMessage').html(msg);
  }
  $(document).ready(function(){
      unchk();
      var unto;
  });
  </code></pre>
  
  <p>When I declared the variable <code>unto</code> within <code>untmr()</code> it did not delay the execution of <code>unmsg()</code>, and when I changed it to global, it stopped executing altogether. Hmmm.</p>