#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Posts
    112
    Rep Power
    0

    Codeigniter jquery


    I'm creating a chat system using Codeigniter and I need to update a textarea with a field in the database each second.
    For that I'm trying to use jquery for the timer but I don't know how I can update the textarea with data from the database, with a call from the jquery function.

    Can you please help?

    My thanks in advanced
    Games Portal:
    http://www.game4tress.com

    Multimidia Studio:
    http://www.studio.game4tress.com
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    You maybe should make the advertising in your signature a bit less blatant. Makes you look like a spammer.

    As to your question: Constantly updating a textarea with external content sounds more than weird to me. Isn't a textarea for people to type text into it? What exactly are you trying to do?
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Posts
    112
    Rep Power
    0
    Well, I followed your advice about the signature. Hope now its ok.

    What I'm trying to do is a chat system.
    1) The user writes the messages and presses enter.
    2) The messages are saved to the database.
    3) The system loads every second, the last 100 messages from the database into a textarea where everyone can see them


    Originally Posted by Jacques1
    You maybe should make the advertising in your signature a bit less blatant. Makes you look like a spammer.

    As to your question: Constantly updating a textarea with external content sounds more than weird to me. Isn't a textarea for people to type text into it? What exactly are you trying to do?
    Games Portal:
    http://www.game4tress.com

    Multimidia Studio:
    http://www.studio.game4tress.com
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    OK, I guess your use of the term "textarea" is a bit mistakable. To me, that's an HTML textarea. But you obviously mean any element that contains text.

    Anyway, there are basically two approaches for reloading content with AJAX: You can render the chat box on the server and send the complete HTML snippet back to the browser. Then your jQuery only has to do $('#chat_box').html(http_response). Or you can only send the raw data, preferable in a structured format like JSON. Then you'll have to do the rendering with jQuery (creating the elements etc.).
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2009
    Posts
    45
    Rep Power
    47
    Believe it or not, before I even began to think about PHP, I wrote exactly what this guy is trying to do. I even have an ASP version. I won't post the code here because Jacques will ridicule me for the security holes, and I'm feeling especially vulnerable right now, what with the holidays coming...*burp*
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2006
    Posts
    112
    Rep Power
    0
    Well, I got a good answer about this problem, the difficulty now is to implment it:
    http://www.daniweb.com/web-development/php/threads/467024/codeigniter-and-jquery-chat
    Games Portal:
    http://www.game4tress.com

    Multimidia Studio:
    http://www.studio.game4tress.com

IMN logo majestic logo threadwatch logo seochat tools logo