November 8th, 2013, 02:31 AM
-
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
November 8th, 2013, 05:12 AM
-
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?
November 8th, 2013, 06:42 AM
-
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
November 8th, 2013, 07:20 AM
-
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.).
November 8th, 2013, 07:54 AM
-
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*
November 11th, 2013, 06:38 AM
-
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