function chat() {
this.waittime = 6000;
this.intUpdate = null;
this.sendChatUpdate = function (msg) {
var Chatmsg = '0';
if (msg > 0) {
Chatmsg = $('#chatmsg');
var m = Chatmsg.val();
Chatmsg.val('');
}
var s = $("#chatnick").val();
var r = $("#chatto").val();
$.ajax({
type: 'POST',
url: 'Chat/ajax/Chat.php',
data: {
S: s,
R: r,
M: m
},
success: function (data) {
this.ProcessChatReturn(data);
},
error: function (data) {
this.ProcessChatReturn(data);
}
});
}
this.getUnreadChat = function (mr) {
var s = $("#chatnick").val();
$.ajax({
type: 'POST',
url: 'Chat/ajax/Chat.php',
data: {
S: s,
UR: 1,
MR: mr
},
success: function (data) {
this.ProcessChatReturn(data);
},
error: function (data) {
this.ProcessChatReturn(data);
}
});
//clearTimeout(intUpdate);
$('#chatbox').show();
}
}
var chat = new chat();
chat.getUnreadChat();
我收到错误“Uncaught TypeError: Object # has no method 'ProcessChatReturn'”
我认为这是因为如果在 jquery ajax 调用内部使用“this”。我想引用我的“聊天”对象,但我认为由于将它包含在 jquery ajax 函数中,它不是。
任何建议如何在该位置引用我的聊天对象?