HI ,

I am creating a social media site, but getting stumped on updating the status comment boxes. Currently, when a user post a comment to a status it updates in REAL-TIME (ajax) on their page, however, it does not on the clients side. How can I build a comment box to read in REAL-TIME?

I am looking into using either node.js, socket.io or websockets, but I am not sure how to get started. NEW to using that development.
I am currently using just JQUERY / AJAX, but I am sure there is another way to show new comments to both client / user without the latency or memory getting full.

Thanks in advance for some help.

Recommended Answers

All 4 Replies

Member Avatar for diafol

Are you talking about a "push"? Ajax won't do anything for this unless you ask it to poll the server repeatedly - not recommended. There are things called comet servers. PHP with ratchet (http://socketo.me/demo) or socket.io with nodejs may suit you.

Yes, I agree. I will rewrite the scripts to poll the server instead. I was hoping for a tutorial or demo of status updates, but I assume it's similar to the chat funtions?

For modern browsers you can look into making ajs socket but you will need to write a custom socket server based on the spec (rfc).

For some reason I cant edit, so... A JavaScript socket*

To expand, you would still use polling for older browsers and use the socket for newer ones.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.