开发者

Update a div tag using Jquery

I want to update a div tag(Holder) which contains a pie chart, I send values to the pie chart everytime the page loads (ResponseMetric.aspx). I am using jQuery for that purpose to update only the div tag(holder) but nothing happens, I change the value in the DB so that on page load a new value is passed. It doesnt do any page load. the values in the pie chart remains the same, where I am going wrong.

<script type="text/javascript" src="scripts/jquery.js"/>

<script type="text/javascript">
    function getRandom() {
        $("#holder").hide("slow");
        $("#holder").load("ResponseMetric.aspx", '', callback);
    }

    function callback() {
        $("#holder").show("slow");
        setTimeout("getRandom();", 4000);
    }

    $(document).ready(getRandom);
</script>

On page load I pass the values to the pie chart which is inside the Holder (Div) 开发者_开发问答tag. the data for the pie chart changes every second so basically the pie chart has to be updated every 4 seconds, but it does not


I tried your code and did only slight modifications in a jsfiddle

$(function() {
function getRandom() {
    alert("getRandom");
    $("#holder").hide("slow");
    $("#holder").load("/echo/html/", 'text', callback);
}

function callback() {
    $("#holder").show("slow");
    alert("callback");
    setTimeout(getRandom, 4000);
}
$(document).ready(getRandom);
 });

And this worked for me, notice the only difference really being not string-encapsulating the function call in setTimeout

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜