TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
erum mirza
NA
428
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
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);
// Send Button event
$div.find(
"#btnSendMessage"
).click(
function
() {
alert(chat)
// console.log(chat.connectionid)
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(
''
);
}
});
// Text Box event
$div.find(
"#txtPrivateMessage"
).keyup(
function
(e) {
if
(e.which == 13) {
$div.find(
"#btnSendMessage"
).click();
}
// Typing
$textBox = $div.find(
"#txtPrivateMessage"
);
var
msg = $textBox.val();
if
(msg.length > 0) {
// chat.server.sendPrivateMessage(userId, msg, 'Type');
}
else
{
// chat.server.sendPrivateMessage(userId, msg, 'Empty');
}
// clearInterval(refreshId);
// checkTyping(chat, userId, msg, $div, 5000);
});
AddDivToContainer($div);
}
here is hub method function
public
void
SendPrivateMessage(
string
toUserId,
string
fromuserid ,
string
message,
string
status)
{
}
Reply
Answers (
1
)
How to return model object from controller after if else?
back button code for asp web form