I am appending a script tag, along with a bunch of other html, to my current document, retrieved from an ajax call. For some reason the script is not running
//Response handling function
function(responseText){
document.getElementById('reportContainer').insertAdjacentHTML('afterbegin',responseText);
}
An example of responseText
's contents:
<h2>You are <em class="won">victorious</em>!</h2>
<h3>Earnings</h3>
...
<script>
alert('dgd');
</script>
All the html is getting applied to the document, including the script, but it is not running, I don't get this alert popping. What may be causing this?