title: How to change div background color using Javascript and Ajax?
body: <p>I am trying to change background color of <code>div</code> using Ajax and Javascript, but my code is not working:</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      window.rowcount=function() {
          var exam = new XMLHttpRequest();
          exam.onreadystatechange = function() {
              if (exam.readyState == 4) {                             
                  var i=document.getElementById("newdata").innerHTML = exam.responseText;
                  if(i==1){
                      document.getElementsById("newdata").style.backgroundColor = green;                  
                  }
  
              }
          }
          exam.open("GET", "demo1.php?", true);
          exam.send(null);
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Where am I wrong in this code?</p>
  
  <p>Any help will be appreciated.</p>