展示“现场”的最佳方式评论
我想在网格中显示用户评论(足够简单),但我也想显示新记录。理论上,用户会在此页面上停留一段时间,添加自己的评论并在其他人进来时查看其他人的评论。
它的行为非常像一个有多个用户发表评论的聊天窗口,尽管我不希望它如此活跃作为一个(我希望它会像 Facebook 墙一样间歇性更新)
我考虑过: - jQuery+AJAX+定时器?
- 网络套接字。 Web Socket 准备好迎来黄金时段了吗? Web Sockets可以用ASP.NET + IIS来实现吗?
我正在寻找一种优雅、干净、快速(低带宽;如果可能的话只加载新评论,弹出旧评论)的解决方案,并且在 ASP.NET/IIS 平台上不那么深奥...不知道如何为了解决这个问题,恳请您的帮助。
谢谢!
聚苯乙烯 我尝试在“评论系统”“显示新记录”“聊天系统”上搜索,但无法完全找到我想要的结果。
I want to show user comments in a grid (easy enough) but I want to show the new records as they come in as well. In theory, the user stays on this page a while, adding their own comments and viewing others' as they come in.
It behaves very much like a chat window with multiple users making comments, though I don't expect it to be as active as one (I expect it to be about as intermittently-updated as a Facebook wall)
I've considered:
- jQuery+AJAX+Timer?
- Web Sockets. Are Web Sockets ready for prime time? And can Web Sockets be implemented with ASP.NET + IIS?
I'm looking for a solution that is elegant, clean, fast (low bandwidth; only load the new comments if possible, popping off the older ones) and not so esoteric on an ASP.NET/IIS platform...not sure how to go about this, kindly requesting your help.
Thanks!
PS
I tried searching on "comment system" "show new records" "chat systems", but couldn't quite hit the results I sought.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
其他人可能有更好的例子,但我正在使用 AJAX 聊天 Web 应用程序。这是我使用 ASP.net 和 JQuery 所做的事情。
HTML:
使用 message.aspx 将新消息记录到数据库中,并查询新记录以添加到 msg div 中。
Someone else may have a better example, but I was playing around with a AJAX chat web app. Here's what I did using ASP.net and JQuery.
HTML:
Use the message.aspx to record new messages into a database and query for new records to add to the msg div.
试试这个
var Interval=2; // 页面加载时
ajax 每 2 秒与服务器同步一次,并且在
鼠标上 ||键盘事件重置间隔为 2,每 10 个 ajax 调用将刷新间隔增加 1 秒。这样您就可以控制服务器负载。并将节省客户端和服务器的带宽。
这些值可以根据您的需要进行调整
Try this
var interval=2; // on page load
ajax syncing with server for every 2 seconds and on
mouse || keyboard
event reset interval to 2 and every 10 ajax calls increase the refresh interval by 1 sec. This way you can control server load. and will save bandwidth for client and server.These values can be adjusted as per your needs