title: Uncaught TypeError: Cannot call method 'open' of undefined
body: <p>This script works on one side but doesn't on the other. It gets an Uncaught TypeError: Cannot call method 'open' of undefined. The script is placed at the same spot on both sides...</p>
  
  <p>This code is used to send a rating to the db 1-5 depending on which the user choose.</p>
  
  <pre><code>function send_ajax(bewertung, click) {
      if (click) {
          alt = userrating[{TOPIC_ID}];
          userrating[{TOPIC_ID}] = bewertung;
          xmlhttp.open("GET", "bewertung.php?{BEWERTUNGSVAR}&amp;wertung=" + bewertung, true);
          xmlhttp.send();
          xmlhttp.onreadystatechange = function () {
              var a = new Date();
              a = new Date(a.getTime() + 1000 * 60 * 60 * 24 * 365);
              if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
                  if (xmlhttp.responseText) {
                      document.getElementById("ratingdesc").innerHTML = "{L_RATINGCOUNTED}";
                  } else {
                      userrating[{TOPIC_ID}] = alt;
                      document.getElementById("ratingdesc").innerHTML = "Bewertung fehlgeschlagen... bitte nochmals versuchen!";
                  }
              }
          }
      } else {
          if (bewertung) {
              document.getElementById("ratingstarbg").style.backgroundPosition = "0 -" + (bewertung * 17) + "px";
          } else {
              if (typeof userrating[{TOPIC_ID}] == 'undefined') {
                  document.getElementById("ratingstarbg").style.backgroundPosition = "0 -{STARTBGPOS}px";
              } else {
                  document.getElementById("ratingstarbg").style.backgroundPosition = "0 -" + (userrating[{TOPIC_ID}] * 17) + "px";
              }
          }
      }
  }
  </code></pre>
  
  <p>and this is how it is called in the HTML</p>
  
  <pre><code>&lt;div style="float:left"&gt;
  &lt;span id="ratingstarbg" class="star" style="background-position: 0 -{STARTBGPOS}px"&gt;
  &lt;a class="ratestar" href="javascript:send_ajax(1,true);" onmouseover="javascript:send_ajax(1,false);" onmouseout="javascript:send_ajax(0,false);"&gt;&lt;/a&gt;
  &lt;a class="ratestar" href="javascript:send_ajax(2,true);" onmouseover="javascript:send_ajax(2,false);" onmouseout="javascript:send_ajax(0,false);"&gt;&lt;/a&gt;
  &lt;a class="ratestar" href="javascript:send_ajax(3,true);" onmouseover="javascript:send_ajax(3,false);" onmouseout="javascript:send_ajax(0,false);"&gt;&lt;/a&gt;
  &lt;a class="ratestar" href="javascript:send_ajax(4,true);" onmouseover="javascript:send_ajax(4,false);" onmouseout="javascript:send_ajax(0,false);"&gt;&lt;/a&gt;
  &lt;a class="ratestar" href="javascript:send_ajax(5,true);" onmouseover="javascript:send_ajax(5,false);" onmouseout="javascript:send_ajax(0,false);"&gt;&lt;/a&gt;
  &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>