SyntaxError when using jQuery.html to insert an HTML fragment containing a script element

I am using jQuery ajax request that gets HTML content from backend code. If the status is ok, I add the HTML content to the div. I am using the following code to add a div using jquery ajax. how $('#divElm').html(response.data);. But after adding, I get the following error:

SyntaxError: missing} in the compound statement

Processing HTML content from the backend (i.e. response.data) contains the following that causes this error:

<script type="text/javascript"> 
function init() {
if(d.getElementById('normal')){
    window.normalPop= d.getElementById('normal');
    //complicated is local 
    var complicated= normalPop.parentNode.removeChild(normal);
    d.getElementsByTagName('body')[0].appendChild(complicated);
    }
}   
addLoadEvent(init);
</script>

I am not sure why this error "SyntaxError: missing" in the compound instruction is "approaching". Brackets close properly in code.

If I use innerHTMLinstead html(), it works fine. Error rendering.

+5
1

The.html() .append(), inturn domManip(), script sniffing . script, , "SyntaxError: missing" ". script, (//) script JS. (//) (/** **/). . .

+2

All Articles