Ajax and Rails with two people?

You need something on the server side to tie the two people together.
Javascript can only communicate with the server it's being served
from. You can send ajax requests every few seconds to the server to
pick up new events that have happened. Can lead to a very busy server

Also, if you have a lot of ajax calls I suggest just using prototype
directly and not use the rails helpers. It can improve performance
quite a bit.


Dave A. wrote:

I'm looking for a little guidance for a project I'd like to start. I'm
fairly familiar with Rails, but still new to Ajax. I want a part of an
app to include a back-and-forth between two people, kind of like a
turn-based strategy game. Is Ajax able to do something like that? Can it
observe when one person has passed it over to the other, and activate
the second person's screen accordingly?

Google for my street name, "how to chat", Rails, and Ajax.

The best raw Ajax can do is a periodically_call_remote with a timer set to above a second. If you try to go faster than that, the internets' pipes will start thrashing.

If you need split-second resolution, then you need a system that leaves an internet connection open. That would be Juggernaut; it uses a small Flash dot on your screen to call-back to the server and leave this connection open. You can get sub-second resolution like this, and both browsers generally see the update at the exact same time.