Hi to all
I have a problem with .load(). I have a html file on the server that i'm trying to load into a container div. The html file contains <script></script> tags. The script isn't render properly when it's executed.
This is an example of what i mean (please ignore minor syntax errors):
index.html:
-----
$(document).ready(function(){
$('.button').live('click',function(){
$('.container_div').load('test.html?nocache=' + randomString());
});
}
test.html:
-----
<div class="count_wrapper" style="background-color:red">
<script type="text/javascript" language="javascript">
for(i=0;i<10;i++){
document.write('this is number ' + i +'<br />'); *
}
</script>
</div>
In the above example when test.html is loaded into the container it completely wipes the index.html page clean (white) and only 'this is number 0' ... 'this is number 9' is written.
If the line indicated with a * is written like this:
this.write('this is number ' + i +'<br />');
then index.html is preserved but there is no output from the write function.
I've also tried $(this).append('this is a number ' + i +'<br />');
But for obvious reasons that didn't work.
Is there a way that i can load script into a container div and have it execute write functions. If the data loaded via AJAX has to be static then I would have to write tonnes of HTML rather than have the client browser do it.