当我尝试从客户端调用服务器端的 SendNewOrderConfirmation 时,我得到
“未定义”不是函数
在线 chat.SendNewOrderConfirmation(data);
有人知道为什么会这样吗?谢谢
在服务器端
public class DriverChat : Hub, IDisconnect
{
public void Start(Driver d)
{
...
}
public void SendNewOrderConfirmation(OrderDriverData data)
{
LogFile.LogResponseTime(data.orderId, data.driverId);
}
}
在客户端
function begin(args) {
try {
//alert('begin');
chat = $.connection.driverChat;
chat.refresh = function () {
ready++;
};
chat.disconnect = function () {
alert('Server has disconnected');
};
$.connection.hub.start(function () {
chat.start(args);
ready++;
// alert('signalR started');
});
} catch (e) {
alert(e.message);
return e.message;
}
}
function confirmNewOrder(data) {
try{
alert('sending cofirmation');
chat.SendNewOrderConfirmation(data);
alert('confirmation sent');
} catch (e) {
alert(e);
}
};
}