locked
Calling Public Function In Hub Through ButtonClick Works, Won't Work At Dcument Load. RRS feed

  • Question

  • User-224188520 posted

    Hey All, not sure what is going on with my code, here it is.

    (function () {
                var myHub = $.connection.ServerHub;
                $.connection.hub.logging = true;
                $.connection.hub.start();
    
                myHub.client.hello = function (message) {
                    //$("#message").text(message);
                    //alert(message);
                    redirect();
                };
    
                $("#btnClick").click(function () {
                    myHub.server.adduser();
                });
            }());

    I've tried all sorts of combination, I need to call myHub.server.adduser(); on Document.Load, it will not work in anything other then the button click event.

    Am I missing something here?

    adduser is just an insert into my db that captures the connectionid and user name.

    Saturday, April 22, 2017 2:55 AM

Answers

  • User-224188520 posted

    I missed this:

    $.connection.hub.start().done(function () {
                    myHub.server.adduser();
                })

    That did it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, April 22, 2017 3:19 AM