Server to client messages not going through with SignalR in ASP.NET MVC 4

前端 未结 1 1813
忘了有多久
忘了有多久 2020-12-18 10:41

I created a simple test app to reproduce a problem I\'m having in my main app.

I have the following hub class:

[HubName(\"testHub\")]
public class Te         


        
1条回答
  •  有刺的猬
    2020-12-18 11:06

    You're using the wrong syntax:

    var tHub;    
    $(document).ready(function () {
        tHub = $.connection.testHub;
        tHub.client.notify = function (msg) {
            alert(msg);
        }
        $.connection.hub.start().done(function () {
            tHub.server.runMe();
        });
    });
    

    Notice the .client property on the hub to register the callback.

    0 讨论(0)
提交回复
热议问题