Answer the question
In order to leave comments, you need to log in
Pjax, Ajax, Yii2, how to update content on the side of the interlocutor?
The bottom line is that there is a database where the correspondence of many different dialogues is stored, in each dialogue there are two interlocutors. When writing a message, for my part, Pjax works, and without reloading I see what I wrote to the interlocutor, but the interlocutor's correspondence is not updated. What complicates the correspondence itself, updating the page by hand is unacceptable!
How to make sure that the correspondence is updated for everyone who has been written to through Pjax, or just write javascript that will update the content on the side of the interlocutor if a new entry has appeared in the database, and so that this update does not concern those who have not yet been written to.
There is id - the one who wrote, id - the one to whom they wrote, token - a unique correspondence (dialogue).
Please tell me where is the solution. I would be very grateful to know how it looks and works.
Answer the question
In order to leave comments, you need to log in
Of course, you can implement everything through Ajax - send a request that monitors new messages, etc., but this method is a crutch and is only suitable for extremely small projects. In general, php is not very suitable for writing a chat, but since you chose it for some reason, it is better to implement it all based on sockets
I support Maxim Fedorov Your trouble is in the wrong choice of instrument. You need to chat through sockets. With normal ajax it will be difficult.
However, html5 has workers, here is an article, I think what you need:
https://habrahabr.ru/post/132785/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question