Search code examples
javascriptinnerhtmlpartial-page-refreshwordpress

How to autorefresh every 1 minute a single div in single post wordpress with inner page template


How to setup an div to auto refresh? I use Transcript theme for wordpress, in single.php is on call for inner php page:

</div><!-- /innerLeft -->

<?php include (TEMPLATEPATH . '/innerNarrowSidebar.php'); ?>
<?php include (TEMPLATEPATH . '/innerWideSidebar.php'); ?>
<div class="clear"></div>

The code inside innerNarrowSidebar.php

<?php if($trns_options['enArc'] == 1) { ?>
        <div class="widget">
            <h3 class="widget_sTitle_b"><?php _e('Archives','Transcript'); ?></h3>
            <ul>
                <?php wp_get_archives('type=monthly'); ?>
            </ul>
        </div>
    <?php } ?>  

And than in innerpage_120x600.php

I have some google adsense

**NOTE**: I added this code in innerNarrowSidebar.php but dosn't work , the div dosn't autorefresh There is the code that i have added:

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>

<script language="JavaScript">
setInterval( "SANAjax();", 10000 );  ///////// 10 seconds 
$(function() {
SANAjax = function(){

$('#narrowSidebar').fadeOut("slow").load('ads/innerpage_120x600.php').fadeIn("slow");

}
 });
</script>

If this is not possible, how to make an text widget to auto refresh?


Solution

  • As described in comments:

    <script language="JavaScript">
    
    $j(function($) {
    var SANAjax = function(){
      //Add here anticache modificator:
      var rnd=Math.random();
      $('#narrowSidebar').fadeOut("slow").load('ads/innerpage_120x600.php?nc='+rnd).fadeIn("slow");
    
    }
    setInterval(SANAjax, 10000 );  ///////// 10 seconds 
     });
    </script>