title: Javascript simple script doesn't execute
body: <p>I've always been hesitant to learn JS since I have to go out of my way to debug the script. The support for such things is poor compared to IDEs for C#/C++ etc.</p>
  
  <p>I'm trying a simple PHP and JS script to retrieve data from my MySQL database, but "onchange" doesn't seem to be triggered:</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  
  &lt;html&gt;
  
  &lt;head&gt;
  
  &lt;script type='text/javascript'&gt;
  
  function ShowUser(name)
  {
      if(name == "")
      {
          document.getElementById("display").innerHTML = "Please enter a username to check";
          return;
      }
      if(window.XMLHttpRequest)
      {
          xmlhttp = new XMLHttpRequest();
      }
      else
      {
          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
  
      xmlhttp.onreadystatechange = function()
      {
          if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200)
          {
              document.getElementById("display").innerHTML = xmlhttp.responseText;
          }
      };
  
      xmlhttp.open("GET", "index.php?uName=" + name, true);
      xmlhttp.send();
  
  }
  
  &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;form&gt;
  
      &lt;?php
          $data = array();
          if(!empty($_GET['uName']))
          {
              $r = mysql_connect("localhost", "root", "pass") or die("Couldn't connect to db");
              mysql_select_db("db", $r) or die ("Couldn't select db");
              $q = mysql_query("select * from users where uName = '{$_GET['uName']}'") or die("Couldn't query table");
              $data = mysql_fetch_assoc($q);
              mysql_close($r);
          }
  
      ?&gt;
  
      &lt;input type="text" name="fUName" onchange="ShowUser(this.value);" style="width:125px;"&gt;
  
  &lt;/form&gt;
  
  &lt;div id="display"&gt;&lt;?php print_r($data); ?&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>It must be something silly I'm missing. Most of this code was taken from W3schools and put with my own PHP and HTML.</p>
  
  <p>Thanks for any help.</p>