During an AJAX call, I am receiving plain HTML with some JavaScript code. When I try to display this response in a container using .html (jQuery) or innerHTML (plain JavaScript), it removes the <script> tag and all JavaScript code.
However, when I change
<script type="text/javascript">
to <script type="text/xml">
, it preserves all script tags and JavaScript. Unfortunately, the script does not execute and even alert and console.log statements do not work inside it.
Can someone please advise me on how I can keep the <script> tag and JavaScript without changing the type attribute?
Thank you