title: AJAX - replace javascript in page: ajax won't replace the javascript
body: <p>I'm trying to replace a bit of javascript in my page via AJAX, but for some reason, AJAX wont replace it...
  When I use:</p>
  
  <pre><code>    alert(document.getElementById('treintracking').innerHTML);
  </code></pre>
  
  <p>I can clearly see the javascript from the script piece: (this is the opening line of the javascript piece)</p>
  
  <pre><code>&lt;script type="text/javascript" id="treintracking"&gt;
  </code></pre>
  
  <p>For replacing the script I use this:</p>
  
  <pre><code>document.getElementById('treintracking').innerHTML = responseText;
  </code></pre>
  
  <p>So, why does AJAX not want to replace the javascript?
  I've tested, and the php file used to generate the replacement javascript, works fine.
  I also took into account that the to-be-replaced javascript already has  tags around it, so I removed those in the php file.
  But it still wont replace the content...</p>
  
  <p>Also, if it put somefunction() in that javascript, will it then run, or do I have to do something special?</p>
  
  <p><strong>Note: the javascript script is generated in a php file.</strong></p>
  
  <p><em><strong>SOLUTION</em></strong>:
  I am now using this external solution, I don't have a clue how it works, but it works perfectly:
  <a href="http://www.javascriptkit.com/javatutors/loadjavascriptcss2.shtml" rel="nofollow">http://www.javascriptkit.com/javatutors/loadjavascriptcss2.shtml</a>
  [I took the loading script from the page source, as it wasnt in the article itself...]</p>