jquery - Check and do animation when new Ajax data pushed in? -


i'm pulling data database using ajax. best way animations or notification when new data(value) pulled in? instance if value of availability changes blink or highlight particular .box div 3 times.

ajax:

            <script type="text/javascript">              $(document).ready(function(){                  //function data database                 function getrealdata(){                     $.ajax({                      url: 'test_api.php',                      data: "", datatype: 'json',                      success: function(rows) {                       var text = '';                          (var 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);                              text += '<div class="box"><b>availability: </b><span class="av ' + (availability == 1 ? 'avhighlight' : '') + '">'+availability+'</span>' +          '<b> hostname: </b>'+hostname+ '<b> intranet: </b>'+intranet+'<b> timeresponse:</b>'+timerespons;     text += '<br/ ></div>';                           }                         $("#content").html(text);                              }                 });                 }                  //this refreshes data every 2seconds                 setinterval(getrealdata, 2000);                  //call function display data                 getrealdata();               });    </script> 

html output:

availability: 0 hostname: aaa intranet: ttt timeresponse:0.124 availability: 0 hostname: qqq intranet: ttt timeresponse:0.064 availability: 0 hostname: www intranet: ttt timeresponse:0.303 availability: 0 hostname: rrr intranet: ttt timeresponse:0.019 availability: 0 hostname: eee intranet: ttt timeresponse:0.025 availability: 0 hostname: ggg intranet: ttt timeresponse:0.158 

thank help.

replace line 1 of following.

$("#content").html(text); 

to

$("#content").html(text).hide().show("easein"); $("#content").html(text).hide().fadein("slow"); $("#content").html(text).hide().slidedown("slow");     

for more animation, can visit http://www.easings.net


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -