用于 jQuery 未请求的 POST 数据的 jQuery 事件侦听器

发布于 2024-12-08 21:47:15 字数 2101 浏览 0 评论 0原文

我一直在研究 Jappix Mini。我想使用现有的 XMPP 而不是 BOSH 来获得正确的效果,并为未来的开发提供正确的产品。我可以通过 CSS 隐藏实际界面,选择要发送的用户名并输入要发送的消息。 。这一切都运行良好,我正在对现在隐藏的 div 进行更改,并将纯文本添加到页面上的 div,与 Jappix Mini UI 完全分离,每 50 毫秒使用一个 window.setInterval 计时器,但我不希望使用该方法进行生产。我知道我发送给其他用户的消息,但如果必须的话可以重新创建 POST 数据并从 jQuery 中执行 POST 请求。 。 .只是在当前时间点不需要。

我需要的是一种让 jQuery 侦听来自其他用户的传入消息的方法 - 如果我可以捕获传入的 POST 数据,那么我只能在需要时进行更新。

我想要捕获的响应(通过 Chrome ctrl+shift+i)是:

 <body xmlns='http://jabber.org/protocol/httpbind'><message xmlns="jabber:client" to="(myAccount)@(myDomain).com/Jappix Mini (1318160212950)" type="chat" id="33" xml:lang="en" from="thisishidden@(conferenceServerAddress)/(nicknameOfRecipient"><body>this is a test</body></message></body>

这是 POST 标头:

 Request URL:http://(machineWithOpenfire)/http-bind/
 Request Method:POST
 Status Code:200 OK

 POST /http-bind/ HTTP/1.1

 Host: ubuntu
 Connection: keep-alive
 Content-Length: 141
 Origin: http://(webserver/localhost)
 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1
 Content-Type: text/xml; charset=UTF-8
 Accept: */*
 Referer: http://(webserver)/test/index4.php
 Accept-Encoding: gzip,deflate,sdch
 Accept-Language: en-US,en;q=0.8
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
 Cookie: pma_lang=en; pma_mcrypt_iv=74ajr%2FGepsQ%3D; PHPSESSID=71vht8hngec8r5nba8m7uk17p2; JSESSIONID=ahhew73q40f2

有效负载:

 <body xml:lang='en' rid='785696' sid='e96dfc09' xmlns='http://jabber.org/protocol/httpbind' key='eb20cd86dee9cb99416f1a8521c2d9f09852f490' />

响应标头:

 HTTP/1.1 200 OK

 Server: nginx/0.8.54
 Date: Sun, 09 Oct 2011 12:38:42 GMT
 Content-Type: text/xml;charset=UTF-8
 Connection: keep-alive
 Content-Length: 300

抱歉,如果我没有意义,或者答案很明显 - 我已经等了太久了思维正直!

感谢任何可以帮助我的人!我理想想要的是类似于:

PostObject onChange do function ( dataResponse ){
      addANewDivToASeries with Sender's Name, Message from dataResponse
}

I've been hacking away at Jappix Mini. I want to use the existing XMPP over BOSH to get the right effect and have the right product in place for future development. I'm able to hide the actual interface through CSS, choose a username to send to and type a message to send. . this all works well and I'm picking up changes to the now-hidden div and adding plaintext to a div on my page, separate completely from the Jappix Mini UI, every 50ms with a window.setInterval timer, but I don't want to be using that method for production. I know the messages I'm sending to other users, but could recreate the POST data if I had to and do the POST request from within jQuery. . .just no need to at the current point in time.

What I need is a way to get jQuery to listen for incoming messages from other users - if I can catch the POST data as it comes in, then I can update only as I need to.

The response (through Chrome ctrl+shift+i) I want to capture is:

 <body xmlns='http://jabber.org/protocol/httpbind'><message xmlns="jabber:client" to="(myAccount)@(myDomain).com/Jappix Mini (1318160212950)" type="chat" id="33" xml:lang="en" from="thisishidden@(conferenceServerAddress)/(nicknameOfRecipient"><body>this is a test</body></message></body>

Here's the POST headers:

 Request URL:http://(machineWithOpenfire)/http-bind/
 Request Method:POST
 Status Code:200 OK

 POST /http-bind/ HTTP/1.1

 Host: ubuntu
 Connection: keep-alive
 Content-Length: 141
 Origin: http://(webserver/localhost)
 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1
 Content-Type: text/xml; charset=UTF-8
 Accept: */*
 Referer: http://(webserver)/test/index4.php
 Accept-Encoding: gzip,deflate,sdch
 Accept-Language: en-US,en;q=0.8
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
 Cookie: pma_lang=en; pma_mcrypt_iv=74ajr%2FGepsQ%3D; PHPSESSID=71vht8hngec8r5nba8m7uk17p2; JSESSIONID=ahhew73q40f2

payload:

 <body xml:lang='en' rid='785696' sid='e96dfc09' xmlns='http://jabber.org/protocol/httpbind' key='eb20cd86dee9cb99416f1a8521c2d9f09852f490' />

response headers:

 HTTP/1.1 200 OK

 Server: nginx/0.8.54
 Date: Sun, 09 Oct 2011 12:38:42 GMT
 Content-Type: text/xml;charset=UTF-8
 Connection: keep-alive
 Content-Length: 300

Sorry if I make no sense, or if the answer is obvious - I've been up far too long for thinking straightly!

Thanks anyone who can help me! What I'd ideally want is something akin to:

PostObject onChange do function ( dataResponse ){
      addANewDivToASeries with Sender's Name, Message from dataResponse
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九公里浅绿 2024-12-15 21:47:15

在 mini.js 文件中查找 handleMessageMini 函数。如果您想访问该消息,只需修改它即可。 Jappix 将在发送时处理接收。

Look for the handleMessageMini function in the mini.js file. Just modify that if you want to access the message. Jappix will handle receiving it when sent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文