javascript - Create List of Elements Added Through Dynamic Polling -


i have jquery function dynamically polls django view of mine every 10 seconds see if new data has been added:

setinterval(function() {     $.get('pollnewentries', {}, newentrysuccess) }, 10000);  function newentrysuccess(result) {     $.each(result, function(index, value) {         var datestring = new date(value.fields.pubdate);         datestring = datestring.todatestring() + " - " + datestring.totimestring();         var title = "<h1>" + value.fields.title + "</h1>";         var authoranddate = "<h4>" + value.fields.author +              " - <time datetime='>" + value.fields.pubdate + "'>" + datestring +              "</time>" + "</h4>";         var text = "<div class='cuttext'>" + value.fields.text; + "</div>";         var html = "<article class='text'>" + title + authoranddate + text + "</article>";         $('#mainleft').prepend(html);     });  }    

});

this works, i've conservatively structured polling interval , view account lag time, view return same article "new" 2 or more separate ajax calls.

what want save id of encountered new articles kind of set. can query against set every time ajax call returns result, ensure article hasn't been encountered before, , proceed if it's new.

i set simple global list (or customized set/dictionary, though amount of articles small there won't of difference in performance) or cookies, think cookie overhead little overkill application , know global particularly toxic in javascript. other suggestions, or going global best option in case?


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -