Welcome to the Treehouse Community
Looking to learn something new?
Why JQuery AJAX request is slow
Hi I am creating a chat app in jquery and I have a problem init when I write a message to my friend it will take time then it will get sent but when I see in Facebook the message will get sent in a second. Why it will take like 4 to 5 seconds while it will get sent.
Dave McFarlandTreehouse Teacher
Hi Dustin Scott
AJAX isn't the best choice for real-time communication like in a messaging app. Each time you make an AJAX request you have to establish a connection with the server -- this takes time. A better real-time solution is using web sockets -- they let you open a connection to a server and keep it open -- the server can push data down to the browser without a specific request.
There are many tutorials on using websockets to create a chat app. Here's one that uses Node.js http://code.tutsplus.com/tutorials/using-nodejs-and-websockets-to-build-a-chat-service--net-34482