I have a custom control kept inside a div that changes its contents only on refresh, so I am thinking to use something that can refresh only the div.I am trying to do face book wall like concept.
try like this
<html>
<head>
<!-- For ease i'm just using a JQuery version hosted by JQuery- you can download any version and link to it locally -->
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
$("#responsecontainer").load("response.php");
var refreshId = setInterval(function() {
$("#responsecontainer").load('response.php?randval='+ Math.random());
}, 9000);
$.ajaxSetup({ cache: false });
});
</script>
</head>
<body>
<div id="responsecontainer">
</div>
</body>
</html>
You can use setInterval to continuosly perform an action. clear it with clearInterval(intv);
var intv = setInterval(function(){
//do stuff here every 5 seconds
}, 5000);
setTimeout(function(){
clearInterval(intv);
}, 30000);
Above will do something ever 5 seconds, then cancel the polling after 30 seconds.