jQuery.load doesn't execute javascript with document.write

Posted by Garfield on Stack Overflow See other posts from Stack Overflow or by Garfield
Published on 2010-04-13T16:38:54Z Indexed on 2010/06/15 3:02 UTC
Read the original article Hit count: 382

Filed under:
|
|

I am trying to use jQuery.Load to load an ad call that has a document.write, and for some reason its not able to, or in firefox atleast, reloads the page with the entire ad.

Here is the simplified version of the code.

DynamicLoad.html

<html>
<head>
<script src="http://www.prweekus.com/js/scripts.js?3729212881" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Load of Script</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
   google.load("jquery", "1.3.2");
</script>
<script type="text/javascript">
   $(document).ready(function(){
    $("#myButton").click(function() {
        $("#myDiv").load("source.html");
    });
   });
</script>
</head>
<body>
<button id="myButton">Click Me</button>
<div id="myDiv"></div>

<div id="slideAdUnit"></div>

</body>
</html>

Source.html

<script language="javascript" type="text/javascript">
  document.write('<script language="javascript" type="text/javascript"><\/script>');
</script>
test

Once you click the button in FF the browser just waits for something to load. Any thoughts ?

Eventually I would be passing a src element in the document.write which points to our ad server.

Thanks for your help.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX