javascript - Second setInterval function is not invoked -
i had working script perform ajax calls , update multiple areas of page using jquery. worked on second set of code create script take string "2 days 19:20", split days, hours , minutes, use setinterval increment string minute minute. worked on own when there 1 setinterval function on page.
now, i've added code main script, using unique variable , function names, , added setinterval function such $().ready
looks this:
$(document).ready (function() { setinterval(function() { communicate_server(); }, serverpollfrequency ); setinterval(function() { updatemyclock(); }, clockupdatefreq ); });
the functions this:
function updatemyclock () { alert("called"); $('.showonline').each(function () { var cl = $(this).html(); cl=splittime(cl); $(this).html(cl); } function splittime (timestring) { ... }
the alert added debug script. issue function communicate_server();
works, updatemyclock()
never called. var clockupdatefreq=1;
set prior $().ready
.
what causing this? if need provide more of code, will.
you have forgot } updatemyclock !
function updatemyclock () { alert("called"); $('.showonline').each(function () { var cl = $(this).html(); cl=splittime(cl); $(this).html(cl); });// close each }// close updatemyclock function splittime (timestring) { ... }
an example of want: http://jsfiddle.net/fryqe/1/
note: use console.log debug ;)
Comments
Post a Comment