首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >创建聊天框HTML/动态web/jquery Ajax

问创建聊天框HTML/动态web/jquery Ajax
EN

Stack Overflow用户
提问于 2011-01-04 03:51:11
回答 1查看 2.5K关注 0票数 0

谁能教我如何在HTML中创建一个聊天框?我使用jquery和Ajax创建动态网页。我尝试使用输入文本框,但我不知道如何让另一个聊天框在其中发布双方的会话。

最小二乘法

EN

回答 1

Stack Overflow用户

发布于 2011-01-04 03:52:53

只要有一个由你的javascript动态更新的DIV即可。

你也可以通过google找到关于这方面的大量教程。像这样的here

特别是,JQuery的这一小部分将为您提供一个思路:

代码语言:javascript
复制
function LoadNewMessages() {
  // Loads new messages from retrieve_new.php file into new_posts div
   $('#new_posts').load("retrieve_new.php");

   // Determines whether or not there is a new message by searching new_posts div
    if (document.getElementById('new_posts').innerHTML != '') {

    // If nothing exists it won't do anything but if there is it will post this:
     $('#chatbox').prepend("
"+document.getElementById('new_posts').innerHTML+"
");

    // This makes it fade in. Not necessary but cool.
     $('#new_message').fadeIn(1000);

    // Empties the div for future posts.
     $('#actions').html("");
   }
}
// Refreshes and checks for new messages.
setInterval("LoadNewMessages();", 1000);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4587776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档