-3
<script>
var refresh;
function refresh(timeoutPeriod){
    refresh = setTimeout(function(){window.location.reload(true);},timeoutPeriod);
}  
makeClientRequest('live','liveFeed','');
window.onload=refresh(5000);   
<script>

I want to call this function every 5 sec. I try that way.but it didn't work.

Roopendra
  • 7,674
  • 16
  • 65
  • 92
A_J
  • 71
  • 1
  • 7
  • possible duplicate of [Call a javascript function after 5 sec of last key press](http://stackoverflow.com/questions/693849/call-a-javascript-function-after-5-sec-of-last-key-press) – Just code Oct 29 '13 at 04:43
  • You are getting the downvotes because it does not appear you have tried to search for your answer. The duplicate question marked above is an exact duplicate -- even the time frame is the same. Please show an effort to research your problem; it is good for you, and good for our community here. Thanks! – Chris Baker Oct 29 '13 at 04:45
  • 1
    In addition to a lack of research, "it didn't work" doesn't help describe the specific problem to us, which makes it more difficult to efficiently help (especially if the code is complex). – ajp15243 Oct 29 '13 at 04:47

1 Answers1

3

Try setInterval instead of setTimeout

refresh = setInterval(function(){window.location.reload(true);},timeoutPeriod);

setTimeout will call the function only once after the specified time period. But setInterval will call the function on specified interval of time

Nauphal
  • 6,194
  • 4
  • 27
  • 43