SignalR, Not a Function -


i trying send data sql server. model @ hand. got error saying addbug not function. post:29 uncaught typeerror: chat.client.addbug not function can please me in debugging error. cannot find mistake , sorry totally new signalr , trying somethings , running server.

client-side

    <script src="~/scripts/jquery-1.10.2.min.js"></script> <script src="~/scripts/jquery.signalr-2.2.0.min.js"></script> <script src="~/signalr/hubs"></script> <meta name="viewport" content="width=device-width" /> <title>post</title> <script>     var chat;     $(document).ready(function () {         chat = $.connection.additems;         console.log('connection done');         $.connection.hub.start();         console.log('connection secured');     });     function test() {         console.log('clicked');         var = {             id: $('#txtid').val(),             name: $('#txtname').val()         };         console.log('finish a');         chat.client.addbug(json.stringify(a));         console.log('error');     }; </script> 

my hub class

using system; using system.collections.generic; using system.linq; using system.web; using microsoft.aspnet.signalr; using webapitest2.models; using system.data.entity; using microsoft.aspnet.signalr.hubs;  namespace webapitest2 {     [hubname("additems")] public class queryhub : hub {      public void addbug(test bug)     {         try         {             using (var db = new testdbentities())             {                 var b = db.tests.create();                 b.id = bug.id;                 b.name = bug.name;                  db.tests.add(b);                 db.savechanges();                 int id = b.id;                  clients.others.addbug(b);                 clients.caller.addmebug(b);             }         }         catch (exception ex)         {             clients.caller.reporterror("unable create bug.");         }     } } } 

controller

        public actionresult post()     {         return view();     } 

//hub code  public void addbug(string id, string name)  {     //your code }  //js server call  window.chat.server.addbug($('#txtid').val(), $('#txtname').val()); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -