Hello I work at a page that initially displays a list with registered users in a contest (an user can be registered multiple times, but every user registered is displayed just once), and this list is updated at a certain time period with AJAX, I would like to display just users that aren't already in that list. Which option would be the best to use for this?
- Sending the array with the users from the page to the server, and PHP would compare this array with new users and return just users that aren't already in that list (this mean开发者_JAVA技巧s that I will send to the server a array with about 10-200 users, at every 30 seconds)
- Comparing AJAX result with the list of users from the page, and displaying just users that aren't already in the javascript Array (this means that the comparation will be made with javascript)
It's probably good to do something like this:
- Javascript: Send time last modified to server - Whenever the last new user was added to the list, not the time of the last request. At first this time will be the current time.
- PHP: Return all users that have entered the contest since this time.
- Javascript: If there are results, detemine which users are unique (however you wish) and add them to the list, updating the time last modified for the next request.
I would think this would be the least amount of data transfer if that is what you are concerned about.
精彩评论