通过jQuery加载DB,间隔“加”允许无限滚动以附加旧数据

I am facing a problem with the two options are merged into one.

On one hand, loading content through jQuery.ajax() is working fine. On page loading the news, updateNews() is called which uses jQuery.ajax() to pull content from the database. It then sets up an interval, setInterval() to call the function every 50sec to update the pages with new data coming in from a site (i.e. twitter).

setInterval(function () {updateNews();},50000); 

On the other hand, loading content from the database when a user scroll to the bottom of the page is working fine. The code, based on a defined number of rows per query (limit), pulls the results needed to and based on $(window).scroll() position, gets the data

$.post('get_entries.php',{'group_no': group_no}, function(data){});

Now the problem comes when putting these two together. I want new content to continue coming in through the set interval while also allowing the user to scroll down and get older content/news. When I tried to put those together without an idea on how to get them to jive together, I ended up with two problems (at least):

  1. Loading new content, updateNews() function, when the user is at the bottom of the page reset the page position to the top of the page.
  2. When the updateNews() content is loaded, the SCROLL event fires (since the page height and scroll change due to the new content coming into the page) causing the loading of extra content without user interaction.

Can someone give me some hints, help, links, example.