尝试订阅SignalR中心事件时出现以下错误:
$。connection.hub.connectionSlow不是函数
我的代码:
var connection = $.hubConnection();
serviceRequestHubProxy = connection.createHubProxy('myHub');
connection.start()
.done(function () { alert('connected!'); });
$.connection.hub.connectionSlow(function () {
alert('connection slow!');
});
我正在使用SignalR 2.2。我做错了什么?
答案 0 :(得分:1)
如果您未使用生成的代理,则$ .connection将不可用。你应该改为。
var connection = $.hubConnection();
serviceRequestHubProxy = connection.createHubProxy('myHub');
connection.start()
.done(function () { alert('connected!'); });
connection.connectionSlow(function () {
console.log('We are currently experiencing difficulties with the connection.')
});
阅读more