title: NOT_FOUND_ERR: DOM Exception 8 - javascript
body: <p>My code:</p>
  
  <pre><code>function SubmitCommentAJAX(i)
  {
      var thecomment = i.parentNode.getElementsByClassName("styled")[0].innerHTML; 
      var commentBox = document.body.getElementsByClassName("commentsScroll")[0];
      var request = "http://localhost:8080/ituned.com/index?Event=Comment&amp;PostTitle=&lt;%=p.getTitle()%&gt;&amp;PostOwner=&lt;%=p.getUsername_of_Owner()%&gt;&amp;comment="+thecomment;
  
      xmlhttp.open("POST",request,true);
      xmlhttp.send();
      xmlhttp.onreadystatechange=function()
      {
          if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
          {            
              var response=xmlhttp.responseXML.getElementsByTagName("theComment")[0].text;
              **commentBox.insertBefore(response, commentBox.firstChild);**
          }
      };
  }
  </code></pre>
  
  <p>HTML:
      
          
          </p>
  
  <pre><code>&lt;div class="commentsScroll" align="left"&gt; 
      &lt;div&gt;&lt;/div&gt;             
      &lt;/div&gt; 
  &lt;/div&gt;
  </code></pre>
  
  <p>I get error:  NOT_FOUND_ERR: DOM Exception 8  for the line                                                                              <strong><code>commentBox.insertBefore(response, commentBox.firstChild);</code></strong></p>
  
  <p>But commentBox is well defined because when I check with alert(commentBox) it shows me the object.</p>
  
  <p>What is the mistake?</p>