Div Tag With Ajax Refresh

I’m using yii extension to draw graphs in my Yii application. The graph is to monitor the traffic of user. I want to refresh a <div> using jquery and ajax…

if there are two files in my view/abc folder

1–> a.php

2–> b.php

in file a ,i have written something like this:

[b]

<script type="text/javascript">

jQuery(function($) {

    function updateData()


    {


            var html = &#036;.ajax({


                    url: &quot;&lt;?php echo &#036;this-&gt;createUrl('abc/b'); ?&gt;&quot;,


                    success: function(data) {


                            &#036;('#mydiv').html(data);


                    }


            });


    }


    


    updateData();

var auto_refresh = setInterval(function(){

            updateData()


    }, 1000);

});

</script>

<div id=‘mydiv’> hii </div>

[/b]

in file b,

<?php

echo "Hello…";

?>

i.e i want to refresh <div> written in file a with the content of file b in every 10 seconds

pls help me out!!

:blink: :-[

Try this code




<?php

$url=$this->createUrl('site/b');

Yii::app()->clientScript->registerScript("refresh","

function updateData()

{

    $.ajax({

        'url':'".$url."',

        'success':function(data){

            $('#mydiv').html(data);

            }        

        });

}


updateData();


var auto_refresh = setInterval(function(){

            updateData()

}, 1000);

");

?>


<div id='mydiv'> hii </div>



http://www.yiiframework.com/forum/index.php/topic/49527-update-content-with-ajax-and-ajax-auto-refresh-div/page__view__findpost__p__230887