Web Analytics Made Easy -
StatCounter Ajax add to pre-existing array? - CodingForum


No announcement yet.

Ajax add to pre-existing array?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Ajax add to pre-existing array?

    Hey CF,

    I've been meaning to learn the answer to this question for a long time, I guess now is the time and place to hopefully have it answered.

    I'm wanting to know if there is a technique one can use to have Ajax request live data from a database as it happens but I want it to do this with out having to request a bunch of other information with it.

    Imagine you come to a webpage and there is the latest 10 comments on a video. Let's say that I want new comments to arrive as they happen (say every 5 seconds we will do an Ajax hit on the server). Let's say for sake of argument there is 2 new comments. Is there a way to make Ajax only request and display the latest 2 comments with out having to refresh the 10 latest as well?

    If this sounds confusing, try imagine the 10 comments as an array. I just want to pop one off the end and push a new one onto the front.

    Any tips in the right direction would be great to hear.