0

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't know how to have another chat box to post the session from both parties in it.

LS

RAS
  • 8,100
  • 16
  • 64
  • 86
Lava
  • 11
  • 1
  • 4
  • 1
    possible duplicate of [How to implement a chat room using Jquery/PHP?](http://stackoverflow.com/questions/4174521/how-to-implement-a-chat-room-using-jquery-php) – Adam Kiss Jan 03 '11 at 19:54

1 Answers1

2

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);
Dan McGrath
  • 41,220
  • 11
  • 99
  • 130