Javascript: setinterval start and stop function?
<p>I'm tying to create stop and start functions for a setinterval.</p>

<p>I have been trying everything but I can't seem to get it right!</p>

<p>this is my code:</p>

<pre><code>function myStartFunction() {
var myVar = setInterval(function(){ myTimer() }, 6000);

function myTimer() {

    $.ajax({
      type:"post",
      url:"myphppage.php",
      datatype:"html",
      success:function(data)
      {  
         if(data!="")
         {



         }
      }
    });

}

}

function myStopFunction() {
    clearInterval(myVar);
}
</code></pre>

<p>and this is how I've been trying to call them (This is how I NEED to call them):</p>

<p>to start it:</p>

<pre><code>myStartFunction();
</code></pre>

<p>and to stop it:</p>

<pre><code>myStopFunction();
</code></pre>

<p>but this is not correct and I know it.</p>

<p>could someone please advise on this issue as I've practically been pulling my hair out!</p>

<p>Thanks in advance.</p>