Answer the question
In order to leave comments, you need to log in
How to implement dynamic content update on the site?
Good evening!
The site has posts that I get from the DB. The whole point is that I implemented getting content as follows:
1. The user adds a record.
2. She immediately appears on the site.
I implemented the steps above by:
function showPopularPosts() {
$.ajax({
type: 'post',
url: "/getpopularpost.php",
cache: false,
response: 'text',
success: function(html) {
$("#getPopularPosts").html(html);
}
});
}
$(document).ready(function(){
showPopularPosts();
setInterval('showPopularPosts()',1000);
});
Answer the question
In order to leave comments, you need to log in
we all
create the event entity incorrectly. Let's add the "New Like Added" event to the database and listen to these events on the backend (socket.io, pusher.com or our server) through the socket.
In practice, we create an Event model + Event.User, Event.Project connections. Each Event will have a listener field, let's say 'click'. On the client, we add a listener for each event, and if the event fired, we push the notification to the backend, on the back we update the database and push the notification to the client of the type "New like added" event fired in the browser, display the event
And what is the meaning of the "I like" functionality. Logically, with your Ajax request, you should not only update the posts, but also all the dynamic dependencies associated with the posts, including I like
UPD and it’s really not enough for a second, if 50 people come to the site, they will put a server for you
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question