SignalR $ .hubConnection () not working

I am trying to implement a chat module in an ASP.NET MVC 4 application based on the example here . Since this one, without using the latest version of SignalR (0.5.3), I had to configure the code to make it work.

The problem is that I couldn't even get hubConnection to work. I am facing a JS error that says:

Uncaught TypeError: Object function ( selector, context ) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init( selector, context, rootjQuery ); } has no method 'hubConnection' 

I'm not sure why there is no hubConnection method. I have the latest jQuery and SignalR libraries, and I just followed the SignalR 0.5.3 release notes here . Here is a snippet of generated code in my view:

 <script src="/Scripts/jquery-1.8.2.js"></script> <script src="/Scripts/jquery.signalR-0.5.3.js"></script> <script type="text/javascript" src="/signalr/hubs"></script> <script type="text/javascript"> $(function () { var connection = $.hubConnection(); var chatHubClient = connection.createProxy("chatHub"); connection.start(function () { chatHubClient.join('TEST'); }); }); </script> 

Hope someone can point me in the right direction. Thanks.

+4
source share
1 answer

I assume you followed the walkthrough that appeared with the 0.5.3 announcement? http://blogs.msdn.com/b/webdev/archive/2012/08/22/announcing-the-release-of-signalr-0-5-3.aspx

make sure that you can open both /Scripts/jquery.signalR-0.5.3.js and / signalr / hubs in the browser.

+5
source

Source: https://habr.com/ru/post/1437108/


All Articles