I'm making an AJAX request to retrieve some JavaScript wrapped in <script>
-tags that should be inserted on the current page. How can I make the inserted code execute upon insertion?
I'm using this snippet to append the code:
function drawOutput(responseText) {
var container = document.getElementById('output');
container.innerHTML = responseText;
}
The HTML retrieved (responseText
) looks something like this:
<script>
console.log('Injected!');
</script>
So how can I make the <script>
tags execute?