[英]Strophe.js Notification Received (Composing)
I am trying to get notified when typing. 我正在尝试在输入时得到通知。
<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;
}
But it does not work :( 但这不起作用:(
Please help! 请帮忙!
PS. PS。 Сomplete script http://sitechat.ru/tests/chat1/ 完整脚本http://sitechat.ru/tests/chat1/
You need to parse the response as XML in onNotificationReceived(msg)
您需要在onNotificationReceived(msg)
中将响应解析为XML
var msg = $.parseXML(msg);
And I think you meant 我想你的意思是
jid = $(msg).find('message').attr('from');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.