Hack Forums
[Help] AJAX calls and jQuery - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: [Help] AJAX calls and jQuery (/showthread.php?tid=5157254)



AJAX calls and jQuery - Svnday - Feb 3, 2016

Alright, so I have a very web application that has a chatting feature. This chatting feature is literally just a PHP script refreshed every second thanks to AJAX calls on setTimeout. Since it is so AJAX heavy, a few players from Oceania are having latency issues, so the chat system is not exactly instant. I get that the main issue is via the network, but is there a more effective way than just using setTimeout/setInterval?

I feel as if I should stray away from jQuery for this chat system, and maybe move to a socket chat. However, the only library I know is jQuery. What is a good alternative that will be fast and lightweight?


* - Remix - Feb 3, 2016

No need to refresh the site
You just could call an API for the new messages and edit the html elements with jQuery


* - JIM NASIUM'S GYMNASIUM - Feb 3, 2016

The sooner you ditch jQuery, the better off you will be as a developer.

Take a look at Socket.io


* - Exemplification - Feb 4, 2016

(Feb 3, 2016 05:21 PM)JIM NASIUMS GYMNASIUM Wrote:  The sooner you ditch jQuery, the better off you will be as a developer.

Take a look at Socket.io

Socket.io is absolutely beautiful.

A chat application is their getting started guide --> http://socket.io/get-started/chat/


* - +Haze - Feb 6, 2016

(Feb 3, 2016 05:21 PM)JIM NASIUMS GYMNASIUM Wrote:  The sooner you ditch jQuery, the better off you will be as a developer.

Take a look at Socket.io

Uh no that doesn't even make sense. You shouldn't even be using Ajax for a chat application, sockets is better suited. And also, jQuery is widely used and popular JS library.


* - JIM NASIUM'S GYMNASIUM - Feb 6, 2016

(Feb 6, 2016 09:07 AM)+Haze Wrote:  Uh no that doesn't even make sense. You shouldn't even be using Ajax for a chat application, sockets is better suited. And also, jQuery is widely used and popular JS library.

Right... which is why I told him to take a look at Socket.io.

jQuery used to be very widely used, but there is a big push to move away from it to reduce the amount of overhead that it brings as a side-effect. If you only use jQuery for AJAX, for example, use something like superagent instead, which was built for doing only AJAX. That way, you don't bog down your client with this huge jQuery dependency when you're only really using one of its features.