user2005848
user2005848

Reputation: 406

Reload Div content on interval with jQuery

I am trying to modify a page so that I can reload the content of a div on an interval. This is what I tried:

    $("#thediv").load("/thecontent.php");
        setTimeout(doPoll,1000);
    }

However, using Fiddler reveals that the requests are never made.

Upvotes: 0

Views: 871

Answers (2)

Mouhamad Ounayssi
Mouhamad Ounayssi

Reputation: 361

var content = ''; // file
var element = ''; // id or class

$(window).load(function(){

window.setTimeout("doPoll()",1000);

});

function doPoll(){
  (element).load(content);
}

Upvotes: 0

codebased
codebased

Reputation: 7073

Try with this one:

$(document).ready(function() {
    setInterval(function() {
        $("#thediv").load("thecontent.php");    
    }, 3000);
});

Upvotes: 2

Related Questions