Automatic userlist update
I have a online user list开发者_StackOverflow中文版 which is populated by a SQL query to a database table.
When a new user comes online, how can i make the webpage automatically update?
What code do I need to provide? Thanks
There are a few ways you could do this, but I'll avoid the most tempting WebSockets HTML5 new-ness and suggest the following:
- When a user logs on, record the fact that they are logged on to the database.
- From your page, poll a service or web page method that lists online users.
- If the list changes, update the part of the page that shows the users.
That's the rough outline of what to do. If you need specifics please say what server-side host and programming language you are using. From the client side, please also mention what JavaScript framework you'd prefer or are open to.
精彩评论