Dynamically added script causes problems

Posted by Derk on Stack Overflow See other posts from Stack Overflow or by Derk
Published on 2010-12-21T18:46:34Z Indexed on 2010/12/21 18:54 UTC
Read the original article Hit count: 254

Filed under:
|

I'm loading an html snippet via ajax to append to a div (I use jquery). A part of the html loaded with ajax looks like this:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var options = {
    mapTypeId : google.maps.MapTypeId.TERRAIN
}
alert('test');
var map = new google.maps.Map(document.getElementById('map-canvas'), options);
</script>

Then this is appended with

contentBox.append(data);

The problem is that this causes a black page in Firefox which keeps loading. In other browsers it seems that the code is not executed at all.

Is there a solution for this?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about AJAX