javascript - Get changes in JQuery Ajax request -


my apologies if seems dumb, how implement function when ajax data changed last request?

window.setinterval(function(){     $.get("feed", function(data){          if (data.changed) {              $('#feed').html(data);          }     }); }, 500); 

something cache data , compare after each request?

var data;  window.setinterval(function(){     $.get("feed", function(newdata){          if (data !== newdata) {             data = newdata;             $('#feed').html(data);          }     }); }, 500); 

also, 500ms regular checking requests, i'd advise changing 5000ms or something.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

oracle - Changing start date for system jobs related to automatic statistics collections in 11g -