开发者

Chat box creation HTML/dynamic web/jquery Ajax

Can somebody show me how to create a chat box in HTML ? I'm using jquery and Ajax for a dynamic webpage. I tried to use the input text box but I don'开发者_C百科t know how to have another chat box to post the session from both parties in it.

LS


Just have a DIV that is dynamically updated by your javascript.

You can also find numerable tutorials for this via google. Like this one here

In particular, this little section of JQuery will give you an idea to work from:

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜