title: Pressing a button to run a php script which echos a javascript script
body: <p>Here is the end of the javascript which runs when the button is clicked</p>
  
  <pre><code>xmlObj.open ('GET', /ajax.php, true);
  xmlObj.send ('');
  }
  </code></pre>
  
  <p>So this executes the php script ajax.php in the root directory:</p>
  
  <pre><code>&lt;?php
  echo "&lt;script type='text/javascript'&gt;\n";
  echo "var e = document.getElementById('widget_more_');\n";
  echo "e.innerHTML += '&lt;p&gt; &lt;a&gt;TEST&lt;/a&gt; &lt;/p&gt;';\n";
  echo "&lt;/script&gt;";
  ?&gt;
  </code></pre>
  
  <p>Which is a javascript code that searches the html document for the element by id and appends the TEST link to it. I have ran this javascript in the html normally without trying to echo it through php and it works! BUT not when I try to do it through php! What am I doing wrong?</p>
  
  <p>The reason I am doing it this way is because TEST is actually going to be a string from a php variable.</p>
  
  <p>Please advise me.</p>
  
  <p>Thanks.</p>