dmecke / ChatBundle

MIT License
15 stars 13 forks source link

Don't require page reload to post message #5

Closed mgersten-caxy closed 11 years ago

mgersten-caxy commented 11 years ago

This PR uses jQuery to post the message and update the listing. I pulled the setTimeout function out of the updateChat function so that I can call it after the post. If I would've left it in there, you end up with multiple interval refreshes. Also changed from setTimeout to setInterval since it's no l longer recreating the timeout each call now.

mgersten-caxy commented 11 years ago

I tried to keep to your code style, please let me know if anything needs fixing.

mgersten-caxy commented 11 years ago

Hold on, this doesn't quite work yet...

dmecke commented 11 years ago

Two things: The id could be a problem as it is very generic. Maybe we should prefix it or give it a less common name at least. And second, the reason why I used setTimeout instead of the setInterval is, that when the server responses very slow, it will get fired with more and more requests if you use setInterval. With the current approach, more requests will only be send if a response arrived first.

mgersten-caxy commented 11 years ago

Ok, I think I've fixed both issues and it seems to work for me now.

mgersten-caxy commented 11 years ago

Ok, I think I've addressed your issues. I rebased on your latest copy and also fixed another bug I found. Is this good now?

mgersten-caxy commented 11 years ago

Is there anything else you need from me for this?

dmecke commented 11 years ago

sorry for the delay! thanks a lot for your pull request!