Pausing setInterval during event?
<p>I have a stopwatch feature that is toggled by a start/stop button.  When the stop button is pushed, the timer stops, and jQuery inserts a row into a table that is preloaded onto the page. </p>

<p>I have another jQuery script running in the background that continously updates that table to maintain fresh data. It's essentially a timekeeper.</p>

<p>However, the issue I have is that when a user pushes the stop button, the setInterval load keeps running, causing the added jquery field to disappear.</p>

<p>I have tried adding a variable to check if the stop button was pushed, and if so, stop the event...but since it's already loaded in the DOM, it didn't seem to work.  Here's the current code:</p>

<pre><code>            $.ajax({
                url: 'getData.php',
                success: function(data) {
                    $("#timesheet").html(data);
                }
            });

            var refreshId = setInterval(function() {
                $.ajax({
                    url: 'getData.php?randval='+ Math.random(),
                    success: function(data) {
                        $("#timesheet").html(data);
                    }
                });
            }, 9000);
</code></pre>

<p>Here's the HTML data that the ajax is loading:</p>

<pre><code>&lt;table&gt;
&lt;tr&gt;&lt;th&gt;Test&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Test&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>I have also tried using append on tr:last, but that just appended it to the tr...rather than creating a new tr.</p>

<p>TL;DR: I want setInterval to not override the field that jQuery adds when a button is pushed, but can't seem to do that since it's coded to change the entire table.</p>

<p>Thanks for any suggestions.</p>
