Note that there are some explanatory texts on larger screens.

plurals
  1. POChecking and comparing new value to the old and do animation based on that
    primarykey
    data
    text
    <p>How do I check if the value has change in DOM? I'm calling Ajax function to pull some data from database. I would like to blink or do some animation the that particular DIV if the new value has been pushed. So when "availability" changes do the animation only ONCE. Only to the DIV where the value has changed.</p> <p>here's my code:</p> <pre><code> //function the get data from database function getRealData() { $.ajax({ url: 'test_api.php', data: "", dataType: 'json', success: function (rows) { var text = ''; for (var i in rows) { var row = rows[i]; var availability = row[3]; var hostName = row[2]; var intranet = row[6]; var timeRespons = row[4]; //console.log(availability); if (availability == 0){ var img = "img/tick.png"; } if (availability == 1){ var img = "img/warning.png"; } if (availability == 2){ var img = "img/alert.png"; } text+= '&lt;section class="square"&gt;&lt;h3&gt; ' + intranet + '&lt;/h3&gt;&lt;img src='+img+' width="70" height="70" rel='+availability+' alt="warning"/&gt;&lt;h4&gt;&lt;img src="img/time_icon.png" width="20" height="20" alt="clock" class="clock" /&gt; '+ timeRespons+'&lt;/h4&gt;'; text += '&lt;/section&gt;'; } $("#journey").html(text); } }); } //this refreshes data every 2seconds setInterval(getRealData, 2000); //call the function to display data getRealData(); </code></pre> <p>many thanks for any help!</p> <p>EDIT</p> <p>the output is :</p> <pre><code>&lt;div id="journey"&gt; &lt;div class="square&gt;availability: 0 hostName: aaa intranet: ttt timeResponse:0.124&lt;/div&gt; &lt;div class="square&gt;availability: 0 hostName: qqq intranet: hhh timeResponse:0.064&lt;/div&gt; &lt;div class="square&gt;availability: 0 hostName: www intranet: nnn timeResponse:0.303&lt;/div&gt; &lt;div class="square&gt;availability: 0 hostName: rrr intranet: rrr timeResponse:0.019&lt;/div&gt; &lt;div class="square&gt;availability: 0 hostName: eee intranet: uuu timeResponse:0.025&lt;/div&gt; &lt;div class="square&gt;availability: 0 hostName: ggg intranet: ooo timeResponse:0.158&lt;/div&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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