我正在尝试在输入时收到通知。
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/strophe.min.js"></script>
connection.addHandler(onNotificationReceived, null, "message", "chat", null, null);
function onNotificationReceived(msg)
{
var composing = $(msg).find('composing'),
paused = $(msg).find('paused'),
active = $(msg).find('active'),
jid = $(msg).attr('from');
if (composing.length > 0)
{
$('.chat-feedback').css('display', 'block');
alert(1);
}
if (paused.length > 0)
{
$('.chat-feedback').css('display', 'none');
alert(2);
}
if (active.length > 0)
{
$('.chat-feedback').css('display', 'none');
alert(3);
}
return true;
}
但它不起作用:(
请帮忙!
PS。 Сomplete脚本http://sitechat.ru/tests/chat1/
答案 0 :(得分:1)
您需要在onNotificationReceived(msg)
var msg = $.parseXML(msg);
而且我认为你的意思是
jid = $(msg).find('message').attr('from');