Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is SignalR a suitable substitute for jQuery Ajax (or similar)

Tags:

As per title, would SignalR be a suitable substitute for general Ajax (e.g. jQuery Ajax) updates used in web pages.

Thanks

like image 413
AnonGuy Avatar asked May 18 '12 14:05

AnonGuy


People also ask

Is SignalR similar to AJAX?

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.

What is a substitute for AJAX?

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.

Should I use AJAX or jQuery?

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.

Can AJAX be used with jQuery?

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!


1 Answers

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.

like image 54
Ian Mercer Avatar answered Jun 18 '23 07:06

Ian Mercer