Skip to content Skip to sidebar Skip to footer

Refresh Div Without Load

I have a div with some content, I want the div to auto refresh every x seconds. I don't want to use load because it will call some other page and the div content is not dynamic. Th

Solution 1:

If I understood your problem, you only want to update the div with a random number all 5 seconds? Then I think this code from my jsFiddle will help you.

functiongetRandomInt() {
    returnMath.floor(Math.random() * 11);
};

functionrefreshDiv() {
    $('#gg1').html(getRandomInt());
};

$(document).ready(function () {
    setInterval(refreshDiv, 5000);
});

Solution 2:

I don't think refresh is a valid command (I could be wrong). I would do something like this:

var cDIVCONTENT = "a";
functionrefreshDiv() {
   gg1.value = cDIVCONTENT;
}
$(document).ready(function () {
   setInterval(refreshDiv, 5000); 
});

This will continually set the value of the gg1 div to be cDIVCONTENT Is this what you want?

Solution 3:

first you create a function for set content

functionchangeDIV()
{
    $('.eg').html('text');
}

and call with inteval

$(document).ready(function()
{
   setInterval(changeDIV,5000); 
});

Post a Comment for "Refresh Div Without Load"