Note that there are some explanatory texts on larger screens.

plurals
  1. POAJAX/MySQL,JavaScript - database and countdown
    primarykey
    data
    text
    <p>I am displaying data from database by Ajax and I need to add countdown timer with times from database. Is it possible to do it as I am struggling with it for about 24 hours. You can look at main code here <a href="http://www.egrupper.pl" rel="nofollow">http://www.egrupper.pl</a> and as you will see the countdown timers are not working. The AJAX code:</p> <pre><code>function showDeals(sid,limit,cat) { sid=typeof sid !== 'undefined' ? a : 1; limit = typeof limit !== 'undefined' ? limit : 0.7; if(sid=="" || limit==""){ document.getElementById("con").innerHTML=""; return; } if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); }else{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if(xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200){ document.getElementById("con").innerHTML=xmlhttp.responseText; $('#con').masonry({ itemSelector: '.clsDeal_Blk_Cont' }); } } xmlhttp.open("GET","getdeals.php?sid="+sid+"&amp;limit="+limit+"&amp;cat="+cat,true); xmlhttp.send(); } </code></pre> <p>and in getdeals.php I have countdown timer code which looks like this:</p> <pre><code>$(document).ready(function(){ $("#countdown_&lt;?php echo $id; ?&gt;").countdown({ date: "date_from_database", format: "on" }, function() { // callback function }); }); </code></pre> <p>thanks @user2008945 for help which was useful for me, but anyway I need more than one countdown timers on page and I though that something like this will do but unfortunatelly not:</p> <pre><code>success:function(rows){ for (var i in rows){ var row=rows[i]; var id=row[0]; var end_date=row[1]; $("#countdown_"+id).countdown({ date: end_date, format: "on" }, function() { // callback function }); } } </code></pre> <p>and</p> <pre><code>$data=array(); while($row=mysql_fetch_row($result)) { $data[]=$row; } die (json_encode($data)); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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