Sunday 15 June 2014

javascript - jQuery - remove list items based off of time -


I currently have a page in which there is an anonymous list that is initially populated by my DB inquiry into the list, Each list item has a time stamp and text, if Javascript and AJAX are to be used, then this page updates dynamically without any inventory every 10 seconds, if the new data has arrived.

What is the easiest and most effective way to remove items from the list from the list, more than 24 hours old?

My tendency is to do the following:

  1. In the js file, load all list items in an array in an unreserved list
  2. To get data during the data, if the data comes back, then add those objects to the array also
  3. Each time the matching () function is called, it also removes a distant data () function Which removes all items that are older than 24 hours

In addition, I have a javascript Attempted to remove the correct way of adding list items to the script array is a code here that I am trying to add to all the list items in an array:

  var list = new array ( ); $ (".listname") Each (function (i) {list.push ($ (this));});  

To delete list items from the array, I expect to use it:

  list.pop (); Why do not array first (oldest first), then use   

? This will remove the first item in the array, as described.


No comments:

Post a Comment