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
- function createPrivateChatWindow(userId, ctrId, userName,chat) {
- alert("createPrivateChatWindow method")
-
- var div = '<div id="' + ctrId + '" class="ui-widget-content draggable" rel="0">' +
- '<div class="header">' +
- '<div style="float:right;">' +
- '<img id="imgDelete" style="cursor:pointer;" src="/Images/delete.png"/>' +
- '</div>' +
-
- '<span class="selText" rel="0">' + userName + '</span>' +
- '<span class="selText" id="msgTypeingName" rel="0"></span>' +
- '</div>' +
- '<div id="divMessage" class="messageArea">' +
-
- '</div>' +
- '<div class="buttonBar">' +
- '<input id="txtPrivateMessage" class="msgText" type="text" />' +
- '<input id="btnSendMessage" class="submitButton button" type="button" value="Send" />' +
- '</div>' +
- '<div id="scrollLength"></div>' +
- '</div>';
-
- var $div = $(div);
-
-
- $div.find("#btnSendMessage").click(function () {
- alert(chat)
-
- alert("send click")
-
- $textBox = $div.find("#txtPrivateMessage");
- var msg = $textBox.val();
- alert("msg is " + msg)
- if (msg.length > 0) {
- chat.server.sendPrivateMessage(userId, $("#connlbl").text(), msg, 'Click');
- $textBox.val('');
- }
- });
-
-
- $div.find("#txtPrivateMessage").keyup(function (e) {
- if (e.which == 13) {
- $div.find("#btnSendMessage").click();
- }
-
-
- $textBox = $div.find("#txtPrivateMessage");
- var msg = $textBox.val();
- if (msg.length > 0) {
-
- }
- else {
-
- }
-
-
-
- });
-
- AddDivToContainer($div);
- }
here is hub method function
- public void SendPrivateMessage(string toUserId,string fromuserid ,string message, string status)
- {
- }