Welcome Guest, Not a member yet? Register   Sign In
jQuery and CodeIgniter Chat Script
#1

[eluser]llbbl[/eluser]
I was working with jQuery tonight and adapted a tutorial off of sitepoint that uses jQuery so that it works with codeigniter. It is a simple chat script where a person enters their name and a message.

Read more about the jQuery Chat script on my site. You have to go there to download it also, if you want to try it out.

You can see it working here. It will only store the last ten lines that people put in the chat. It uses MySQL to store the messages.

I couldn't figure out how to get the message in the input box to clear after you enter something. Maybe someone knows how?

Code:
$("#msg").empty();

I tried .remove() but that just deletes the input box. I think I am going to have to write a function to remove the value explicitly.
#2

[eluser]xwero[/eluser]
Code:
$('#msg').val('');

It's beginning to become a jQuery forum here, maybe there should be a jQuery section but then the other javascript/ajax library users would be jealous Smile
#3

[eluser]CI Lee[/eluser]
That is pretty sweet... I think some sort of flood control is called for though.
#4

[eluser]llbbl[/eluser]
Ok I updated it to version 1.2.

New Features:
# Keeps the focus on the message field.
# Removes what you typed previously.
# Loading animated gif after submitting.

Better?
#5

[eluser]llbbl[/eluser]
Let me know if you have any more ideas.
#6

[eluser]CI Lee[/eluser]
I like it! I may have a use for it in the not too distant future!

Thanks!

-Lee
#7

[eluser]llbbl[/eluser]
your welcome.

It is still not perfect. Sometimes it posts stuff 2x, but just to the msg field. I think it has to do with the query and how it handles time. I spent sometime trying to figure it out, but there is more debugging to be done before we find an acceptable solution.

It doesn't work exactly like the the sitepoint guy wanted. He thought it should only load messages posted after you load the page, but I don't mind that it loads everything, or the last ten messages. It is a minor thing that can be tweaked.
#8

[eluser]Unknown[/eluser]
This may be helpful you.
CodeIgniter Chat example
http://faq.pctrickers.com/codeigniter-chat-example/




Theme © iAndrew 2016 - Forum software by © MyBB