tags:

views:

42

answers:

4

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?

+1  A: 

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()

Pranay Rana
this still not answer the question `Refresh an element in jquery`. Who knows, the OP might already know `setInterval` and just don't know how to use it in this situation.
Reigel
yes I already know setInterval
Jack Shephard
so make use of that will do work for you
Pranay Rana
A: 

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.

Powertieke
A: 
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 );
Night Shade
A: 
setInterval ( "UpdateDivID()", 5000 );

function UpdateDivID()
{

$('#AnchorID').html('Someone has refreshed the page');

}

Will change the html of the AnchorID.. Be more specific.

Thqr