Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation automatic div refresh

    Hi, a newbie to Ajax here so easy to understand answers, please


    Im trying to build a VERY simple chat function on a page.

    I have one text field, when someone types into this and clicks enter, the text is automatically written to the database (im using PHP and mySQL). I have this bit working fine.

    Just above this text field I have a div tag which pulls all the entries out of the database. I need this to automatically refresh (say every 10 seconds) without any input or changes from the user. How can I do this?

    any help would be very much appreciated

  • #2
    New Coder
    Join Date
    Jun 2009
    Location
    Bangalore, India
    Posts
    42
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Try this:

    Code:
    function updateTextBox() {
        //Get info from server
        //and update the text box/whatever
    }
    textBoxUpdateInterval = setInterval(updateTextBox, 10 * 1000);

  • #3
    New Coder
    Join Date
    Jun 2006
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, but as I said im a complete newbie to ajax. Where do I actually put that code you gave me? and how does it tie in with my chat area (the div id is "ajaxChat")?

    cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •