jquery - Using ajax, how to get notify only if there is any update in the received data -


$(document).ready(function refreshtext(){ $.ajax({          type: "post",         url: "user.php",         data: "data1=1",         success: function(result){          $(".msg").html(result);          settimeout(refreshtext, 5000);          }});     }); 

initially when loads should not notify or alert, after every timeout should alert me if there update in data..exactly how works in chat. 1 please me on this, bit new programming....

just store last result cookie , check on ajax success:

$(function(){     refreshtext(); });  var last_response; // define variable save result function refreshtext(){     $.ajax({          type: "post",         url: "user.php",         data: "data1=1",         success: function(result){             if( result === last_response ) return;             last_response = result;             $(".msg").html(result);             settimeout(refreshtext, 5000);         }     }); } 

Comments