我正在尝试用信号器做一些事情。我的中心是
public class Customer : SignalR.Hubs.Hub
{
public void Send(string uid, string from, string msg)
{
string make = from + uid;
Clients.Addmsg(msg, make);
}
}
客户端代码是
<script src="Scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.signalR-0.5.3.min.js" type="text/javascript"></script>
<script src="/signalr/hubs" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
$(function () {
// Proxy created on the fly
var care = $.connection.Customer;
$("#broadcast").click(function () {
// Call the chat method on the server
care.send($('#msg').val(), "HariOm", "jai jai ram")
.done(function () {
console.log('Success!');
})
.fail(function (e) {
console.warn(e);
});
});
// Declare a function on the chat hub so the server can invoke it
care.Addmsg = function (message, make) {
alert(message + msg);
};
// Start the connection
$.connection.hub.start();
});
</script>
加载页面后出现此错误
未捕获的类型错误:无法设置未定义的属性“Addmsg”