jquery - start and stop ajax auto refresh -
am developing school e-learning- forums module. posts loaded in
<div id="posts"></div>
using function:
var refreshcon = setinterval( function() { $('#postcontainer').load('new/posts.php', function() { }); },5000);
a text box -add new response- inside
<div id=""></div>
and refreshed rest of data. have added function <input type="text" onfocus="stopcounter()"/>
[stop counter clearinterval(refreshcon); , working]. problem is. can't start autorefresh again onsubmit of form. jquery , not friends. please show me simple function start , stop auto refresh @ will. in advance
you can use these functions:-
to start:-
function start(){ refreshcon = setinterval(function(){ $('#postcontainer').load('new/posts.php', function(){ }); }, 5000); }
to stop:-
function stop(){ try{ clearinterval(refreshcon); }catch(err){} }
Comments
Post a Comment