I've played around with ajax chat a bit, but I don't really have a working solution that I'm happy with.
This is gonna be buggy and once you get in the code it should be overly dirty, yet as simple as I could keep it.
I had planned on cleaning it up, fixing the bugs and then posting, but here it is...
http://linardy.com/chat/
I still haven't even taken my own advice to slow down the setTimeout calls when a user has been idle for a certain amount of time. If I were you, I'd move the setTimeout function call to the callback function and do a bit of work to determine how long until the next call. The more amount of time since the user's last action, the longer the Interval. If they've been idle way too long for your taste...provide some sort of feedback letting them know they've timed out with a link or something to get back and dont set the next interval to happen until the user provides some sort of action (post, refresh, js_link, etc...)
I haven't touched the code for a couple months and was just waiting for a bit more time to fool around with it. consider it lgpl and do whatever you want with it.
good luck!