Injected javascript does not execute
<p>I'm trying to write a piece of javascript that integrates a webpage with an external system. Currently, what I have is a very small amount of code that dynamically inserts a script element into the page.</p>

<pre><code>$(document).ready(function() {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://example.com/example.php?arg1=1&amp;arg2=2";
    document.body.appendChild(script);
});
</code></pre>

<p>The JS returned by the external system is a large one-line document.write call which writes a table to the page.</p>

<pre><code>document.write('&lt;table&gt;&lt;tr&gt;&lt;td&gt;blah&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;');
</code></pre>

<p>When I inject this script element into the page, I can see it using a DOM inspector, but the script does not appear to execute. If I put the script element into the HTML manually, the javascript executes just fine (so it's not a same origin policy or malformed html error...), but I'd like it to be dynamic.</p>

<p>Any ideas why the javascript isn't executing?</p>
