Reputation: 39
I'm using signalR
in my project. But I 'm getting this error
'Uncaught TypeError: Cannot read property 'client' of undefined'
my Code is
var notification = $.connection.CounterHubs;
notification.client.inboxMessageCount = function (c) {
ViewModel.InboxMessages(c);
}
thanks for answer
Upvotes: 1
Views: 230
Reputation: 23690
This tends to happen when you haven't included the automatically generated hubs
file into your page.
Include the hubs file into your page:
<script src="http://example.com/signalr/hubs"></script>
If you have included it already, open your developer tools (F12) and check the value of $.connection.CounterHubs;
in your code and verify that it is not 'undefined'.
Upvotes: 0
Reputation: 1574
I guess it is because your hub is written with an Uppercase.
From the documentation:
In JavaScript the reference to the server class and its members is in camel case. The code sample references the C# ChatHub class in JavaScript as chatHub.
So it should probably be:
var notification = $.connection.counterHubs;
See this page on getting Started with SignalR:
Upvotes: 3