Reputation: 23
I have a anchor element on a page that i need to refresh every 5 seconds. It is only one anchor so i do not need a cycle plugin here.
How can I refresh the element i want without reloading the page. Any plugins?
Upvotes: 1
Views: 2694
Reputation: 5343
setInterval ( "UpdateDivID()", 5000 );
function UpdateDivID()
{
$('#AnchorID').html('Someone has refreshed the page');
}
Will change the html of the AnchorID.. Be more specific.
Upvotes: 0
Reputation: 29166
var myIntervalId = setInterval("function_to_execute()", 5000);
This function_to_execute()
will be called every 5 seconds after your page loads. You can put your refreshing code there and it will be executed every 5 seconds.
It does not refresh your page unless you explicitly refresh it inside the function_to_execute()
function.
To cancel this timer, call -
clearInterval ( myIntervalId );
Upvotes: 0
Reputation: 2408
You can use the Ajax functionality in jQuery : Documentation link!
Especialy the .load() method will help.
Please note that this will only work for files located on the same server (a security measure in javaScript). I you want to pull from a remote server, you'll need a server side proxy to fetch the data.
Upvotes: 0
Reputation: 176896
Rather than going for any plug in Make use of setInterval() function for this kind of repeat function :
setInterval ( "doSomething()", 5000 );
function doSomething ( )
{
// (do something here)
}
More : setInterval()
Upvotes: 1