On the backend you could add a timestamp for when items are added to
the database. Then your query would return anything with a timestamp
newer than the last time you asked for items.

in client js: last_request = time();

Then send the time along with your request to the server script.

on the server:

<?php
   $query = "select * from `item_table` where `added_on` <
$_POST[last_request]";
?>

Hope this helps



On Mon, Jan 4, 2010 at 12:11 PM, Apaz <b831...@uggsrock.com> wrote:
> Hello
>
> Lets say we have a database where things are going to be added at
> random times, over the whole day. I want a AJAX script to load new
> items every 5s (its a local database so no problem with spamming it)
> and for each of these items I have to do a AJAX request to get some
> more data...
>
> From the back-end I will get something like:
> unique ID
> time
> number
> name
> text
>
> How do I detect which items I already have added to my site?
> Because If I just get the latest one, there is a chance I miss
> something, so its safest if the back-end returns the latest 5 items,
> or?
> Any example code how to use the unique ID to validate that I got every
> row I wanted?
> Am I thinking completely wrong? I have access to the back-end also so
> I can change what I want..
>
> Help needed! Thanks ;)
>
>



-- 
If you ask me if it can be done. The answer is YES, it can always be
done. The correct questions however are... What will it cost, and how
long will it take?

Reply via email to