Try:
hub.disconnected = function () {
log("Server has disconnected");
};
hub.received = function (data) {
log("Data Received");
};
Question
I'm running SignalR 1.0.1 and am trying to hook into some callbacks in my clientside javascript.
Consider the following code blocks:
var hub = $.connection.FooHub;
hub.disconnected(function () {
log("Server has disconnected");
});
hub.received(function (data) {
log("Data Received");
});
In both instances, I get the following error message: TypeError: undefined is not a function
Clearly, I'm missing something here. Can someone help point me out in the right direction?
Thanks, JohnB
Solution
Try:
hub.disconnected = function () {
log("Server has disconnected");
};
hub.received = function (data) {
log("Data Received");
};
OTHER TIPS
The hub proxy is created using camel-case (as is appropriate for JavaScript). So, if you define FooHub on your server, you access it on the client using $.connection.fooHub, not $.connection.FooHub.