Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDustin Scott
Courses Plus Student 7,819 PointsWhy 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.
1 Answer
Dave McFarland
Treehouse TeacherHi 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
Dustin Scott
Courses Plus Student 7,819 PointsDustin Scott
Courses Plus Student 7,819 PointsThanks Dave.