I am using jQuery 1.4 and I am trying to append DIVs that contain javascript files from another domain. I have the following inline code at the end of the body, just after loading jQuery:
<script src="jquery-1.4.3.min.js"></script>
<script src="scripts.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
var html = "<div><script type='text/javascript' src='http://example.com/foo'></script></div>";
$("#container").append(html);´
});
</script>
The problem is that the output is:
"; $("#container").append(html); } });
and it is not even displayed in #container but at the bottom of the body where the javascript code is.
EDIT: the javascript file inserts html for ads, so it cannot be loaded into the document head.