erum mirza

erum mirza

  • NA
  • 433
  • 0

unable to call hub method

Jun 3 2019 2:03 AM
i have below code /function ,it gives error ,
 
if i check same issue in chrome it says
 
Uncaught TypeError: Cannot read property 'sendPrivateMessage' of undefined
at HTMLInputElement.<anonymous> (LetsChat:180)
at HTMLInputElement.dispatch (jquery-1.10.2.min.js:22)
at HTMLInputElement.v.handle (jquery-1.10.2.min.js:22)
 
in forefox it says below (same issue)
 
TypeError: chat.server is undefinedLetsChat:180:21
  1. function createPrivateChatWindow(userId, ctrId, userName,chat) {  
  2.       alert("createPrivateChatWindow method")  
  3.   
  4.       var div = '<div id="' + ctrId + '" class="ui-widget-content draggable" rel="0">' +  
  5.                   '<div class="header">' +  
  6.                       '<div  style="float:right;">' +  
  7.                           '<img id="imgDelete"  style="cursor:pointer;" src="/Images/delete.png"/>' +  
  8.                       '</div>' +  
  9.   
  10.                       '<span class="selText" rel="0">' + userName + '</span>' +  
  11.                       '<span class="selText" id="msgTypeingName" rel="0"></span>' +  
  12.                   '</div>' +  
  13.                   '<div id="divMessage" class="messageArea">' +  
  14.   
  15.                   '</div>' +  
  16.                   '<div class="buttonBar">' +  
  17.                       '<input id="txtPrivateMessage" class="msgText" type="text"   />' +  
  18.                       '<input id="btnSendMessage" class="submitButton button" type="button" value="Send"   />' +  
  19.                   '</div>' +  
  20.                   '<div id="scrollLength"></div>' +  
  21.               '</div>';  
  22.   
  23.       var $div = $(div); 
  24.   
  25.       // Send Button event  
  26.       $div.find("#btnSendMessage").click(function () {  
  27.           alert(chat)  
  28.        //   console.log(chat.connectionid)  
  29.           alert("send click")  
  30.   
  31.           $textBox = $div.find("#txtPrivateMessage");  
  32.           var msg = $textBox.val();  
  33.           alert("msg is  " + msg)  
  34.           if (msg.length > 0) {  
  35.               chat.server.sendPrivateMessage(userId, $("#connlbl").text(), msg, 'Click');  
  36.               $textBox.val('');  
  37.           }  
  38.       });  
  39.   
  40.       // Text Box event  
  41.       $div.find("#txtPrivateMessage").keyup(function (e) {  
  42.           if (e.which == 13) {  
  43.               $div.find("#btnSendMessage").click();  
  44.           }  
  45.   
  46.           // Typing  
  47.           $textBox = $div.find("#txtPrivateMessage");  
  48.           var msg = $textBox.val();  
  49.           if (msg.length > 0) {  
  50.             //  chat.server.sendPrivateMessage(userId, msg, 'Type');  
  51.           }  
  52.           else {  
  53.              // chat.server.sendPrivateMessage(userId, msg, 'Empty');  
  54.           }  
  55.   
  56.        //   clearInterval(refreshId);  
  57.        //   checkTyping(chat, userId, msg, $div, 5000);  
  58.       });  
  59.   
  60.       AddDivToContainer($div);  
  61.   }  
here is hub method function
  1. public void SendPrivateMessage(string toUserId,string fromuserid ,string message, string status)  
  2. {  
  3. }

Answers (1)