Reputation: 360
Heey everyone! I was doing a project using Laravel, and now I get to the point to make a private one-to-one chat. So far I made chat using Database, which requires reloadings and etc. But I want to enhance it, so that is was really good, with stuff like: writing, automatic receiving and sending (without reloading page).
What can you offer and why?
Upvotes: 0
Views: 400
Reputation: 620
Use ajax or websocket.
In ajax, you can simply fetch new messages and update the DOM by using setInterval.
function start() {
$start = setInterval(function() {
fetch_chat_messages();
}, 3000);
}
start();
The only disadvantage here is that the DOM keeps on refreshing.
While in Websocket, realtime communication will be possible. I will recommend you to use http://socket.io/.
Goodluck!
Upvotes: 1