How to implement the same on jquery? When a user clicks on an arrow, jquery adds a class to it and sends an ajax request to the server — the arrow lights up, is written to the database — this is understandable. And what about after updating the page? When displaying news, make a request to the database and add a “highlight class” to the corresponding arrow or, when voting, write down the id arrows in cookies and then highlight them with javascript, and then how to authorize this array in cookies?
1 answer
Better all that can be done on the server is to do it on the server and not load the user's hardware.
See how VKontakte works. It sends news to the tape with pieces of generated HTML code and does not impose a bunch of handlers on likes and reposts every time the DOM tree changes; just everywhere there is a call to the functions onclick , onmouseenter , etc., right inline. This allows you to work so quickly.
|