Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying of ajax response in a table not working
    text
    copied!<p>I have this script and I don't know what i'm missing here:</p> <pre><code> $(document).on('click','.btn-start-timer',function(){ var id = $(this).val(), time = $(this).parent().parent().find('.rendered_time').text(); //console.log(time) var i = window.setInterval(function(){ var future = addMinutes(dat, 20); //var future = new Date("Dec 12 2013 22:10:00 GMT-0800 (Pacific Standard Time) "); var now = new Date(); //console.log(tim); var difference = Math.floor((future.getTime() - now.getTime()) / 1000); var seconds = fixIntegers(difference % 60); difference = Math.floor(difference / 60); var minutes = fixIntegers(difference % 60); difference = Math.floor(difference / 60); var hours = fixIntegers(difference % 24); difference = Math.floor(difference / 24); var days = difference; $(this).parents('tr:first').find('td .days').html(seconds + "s"); $(this).parents('tr:first').find('td .hours').html(minutes + "m"); $(this).parents('tr:first').find('td .minutes').html(hours + "h"); $(this).parents('tr:first').find('td .seconds').html(days + "d"); if(hours == 0 &amp;&amp; minutes == 0 &amp;&amp; seconds == 0){ window.clearInterval( i ); alert('times up'); } }, 1000); }); </code></pre> <p>And Here is my html: </p> <pre><code> &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Client Name&lt;/th&gt; &lt;th&gt;Service Name&lt;/th&gt; &lt;th&gt;Time&lt;/th&gt; &lt;th&gt;Therapist Name&lt;/th&gt; &lt;th&gt;Status&lt;/th&gt; &lt;th&gt;Actions&lt;/th&gt; &lt;th&gt;Time&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;? $res = mysql_query("select * from rendered_services"); while($row2 = mysql_fetch_array($res)){?&gt; &lt;? $id_no = $row2['t_id']; $selectstatus=$row2['therapist_status']; ?&gt; &lt;tr&gt; &lt;td align="left"&gt;&lt;?php echo $row2['client_name']; ?&gt;&lt;/td&gt; &lt;td align="left"&gt;&lt;?php echo $row2['rendered_service']; ?&gt;&lt;/td&gt; &lt;td align="left" class="rendered_time"&gt;&lt;?php echo $row2['rendered_time']?&gt;&lt;/td&gt; &lt;td align="left"&gt;&lt;?php echo $row2['assign_therapist']?&gt;&lt;/td&gt; &lt;td align="left"&gt;&lt;?php echo $row2['therapist_status']?&gt;&lt;/td&gt; &lt;td align="left"&gt; &lt;button class="btn btn-success btn-small btn-start-timer" value="&lt;?php echo $row2['t_id']; ?&gt;"&gt;Start&lt;/button&gt; &lt;a class="btn btn-success btn-small" data-toggle="modal" href="pay_bill.php&lt;?php echo '?t_id='.$id_no; ?&gt;"&gt;Pay Bill&lt;/a&gt; &lt;/td&gt; &lt;td&gt; &lt;span class="days"&gt;a&lt;/span&gt; &lt;span class="hours"&gt;a&lt;/span&gt; &lt;span class="minutes"&gt;qa&lt;/span&gt; &lt;span class="seconds"&gt;a&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;?php }?&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>My problem is that when I click <code>.btn-start-timer</code> the data or the time is not showing up in the assigned selector. But when I put <code>$(this).parents('tr:first').find('td .seconds').html(days + "d");</code> for example outside the <code>setInterval</code> it works! So what i'm missing in here?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload