As per title, would SignalR be a suitable substitute for general Ajax (e.g. jQuery Ajax) updates used in web pages.
Thanks
They are two different things. SignalR uses WebSockets but ajax uses HttpRequest. In AJAX the client (browser) sends a request to the server and then receives a reply.
Server Sent Events is a really powerful tool that is somewhat similar to AJAX in that it creates a call and is unidirectional, but it works in the other direction.
You can do AJAX requests in plain Javascript, or you can use the jQuery wrappers to make AJAX requests. In the end they're the same, jQuery just makes it easier because it abstracts things. jQuery is not an alternative to AJAX or Javascript, it's just a collection of functions that make everyday tasks easier.
jQuery provides several methods for AJAX functionality. With the jQuery AJAX methods, you can request text, HTML, XML, or JSON from a remote server using both HTTP Get and HTTP Post - And you can load the external data directly into the selected HTML elements of your web page!
If all you need to do is browser-initiated calls to the server triggered by user actions then you should just use jQuery Ajax.
Only use SignalR where the server needs to update the client asynchronously to any user action. Use it in situations where you would traditionally have used a timer and an Ajax call to poll the server repeatedly to see if anything has changed.
In a situation where you have both kinds of call happening you can use SignalR for both the user actions and the server delivered notifications but it may still be easier/cleaner to keep them separate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With