I have a situation where I am adding a script tag, along with other HTML content, to my current document after making an AJAX call. However, the script is not executing as expected.
//Function to handle response
function(responseText){
document.getElementById('reportContainer').insertAdjacentHTML('afterbegin',responseText);
}
Here is an example of what the responseText
might look like:
<h2>You are <em class="won">successful</em>!</h2>
<h3>Profits</h3>
...
<script>
alert('dgd');
</script>
All the HTML elements are being added to the document correctly, including the script tag, but the alert message is not showing up. What could be causing this issue?