Cannot set property of innerHTML
<p>I have a small script which grabs a file and outputs in Javascript. Then after that output i want to edit the innerHTML. </p>

<p>But its saying it cannot set it. "Uncaught TypeError: Cannot set property 'innerHTML' of null"</p>

<p>This is what i have:</p>

<pre><code>function call_file(file,div_id){

var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
    {
    document.getElementById(div_id).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET",file,true);
xmlhttp.send();

}




call_file('test.php','main'); //main = div_id to display content in 
document.getElementById('total').innerHTML = 'test';
</code></pre>

<p>My test.php has:</p>

<pre><code>&lt;div id="total"&gt;&lt;/div&gt;
</code></pre>

<p>I'm wondering why it cannot set? </p>
