I’m attempting to display an external poll(inject a) script within a div using the jquery html() method. I’ve also tried using the .append method instead of .html but same result.
This is the fiddle : http://jsfiddle.net/adrianjsfiddlenetuser/6S3zg/1/
The script is not being displayed within the div. Within Chrome I receive the error : “Uncaught TypeError: Cannot set property ‘innerHTML’ of null “
<div id="toupdate">
</div>
var htmlString = "<script type=\"text/javascript\" charset=\"utf-8\" src=\"http://static.polldaddy.com/p/6343621.js\"><\/script>\
<noscript><a href=\"http://polldaddy.com/poll/6343621/\">New Poll</a><\/noscript>";
$("#toupdate").html(htmlString);
alert(htmlString);
The problem for me was the script. I needed to wait for the pages to load until setting its html content. Error is no longer thrown but content is still not set.
http://jsfiddle.net/6S3zg/6/