【发布时间】:2017-08-22 14:01:49
【问题描述】:
请您建议将我的响应从 signalR 集线器传递给具有回调的函数调用的最佳方法。我尝试使用全局变量来存储回调并在接收数据时调用它,但没有运气.这就是我喜欢做的事情;
school.lib.setmytime = function(_time){
console.log('mytime is :' + _time);
}
school.lib.gettime = data.getservertime(school.lib.setmytime);
var myhub;
data.connection = function(){
$connection.hub.url = 'http://myserver.com:65442';
$connection.hub.start();
myhub = $.connection.adminHub;
myhub.client.getServerTime = function (_time){
//How do i access the callback
//function in data.getservertime so as to return time to the
//school.lib.gettime?
}
}
data.getservertime = function(callbak){
myhub.server.getServerTime();
}
【问题讨论】:
标签: javascript jquery signalr.client