bilal
bilal

Reputation: 658

why hub object is undefined

why hub object is undefined below is the code, I have owin, hub all the classes in my project, howevery am not able to call hub methods?

    <!--Reference the SignalR library. -->


    <script src="../scripts/jquery.signalR-2.2.1.min.js"></script>

    <!--Reference the autogenerated SignalR hub script. -->
    <script src="/signalr/signalr/hubs"></script>
   <script type="text/javascript">
    $(function () {

        //why hub is not created matrixHub = undefined
        var matrixHub = $.connection.MyHub;

        // TODO, callbacks and hub invoker

        $.connection.hub.start();
        debugger;
    });
</script>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>

Upvotes: 0

Views: 211

Answers (1)

Kelso Sharp
Kelso Sharp

Reputation: 972

Your capitalization is wrong, it should be

var matrixHub = $.connection.myHub;

IF your hub class is named MyHub : Hub

The reason for this has to do with how the javascript for the hub is generated, all methods and the hub itself are all created with camelCase names on a javascript client.

Upvotes: 1

Related Questions