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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -