Answer the question
In order to leave comments, you need to log in
How to do dynamic content loading with ajax?
Hello, I am making a simple chat, with authorization, in principle I implemented everything except dynamic content loading, if I understand correctly, then you need to make a route that will simply display all the insides of the chat, and make an interval in js that every n time will change the content to the received data from request to the route, is this approach correct?
Answer the question
In order to leave comments, you need to log in
In small projects, this approach is acceptable, in large and loaded ones it will be unjustified due to the large number of garbage requests to the server, and in such cases a socket is used. If the task is purely to "play around" - the solution is through a setInterval of norms.
In general, everything is a little more complicated, where the time of the last updated message is usually sent to the server, in response, all new records are sent, which are added to the end of the chat window.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question