[nycphp-talk] the stale V in MVC web apps
Rolan Yang
rolan at omnistep.com
Wed Mar 4 12:45:31 EST 2009
John Campbell wrote:
> On Wed, Mar 4, 2009 at 12:10 PM, David Mintz <vtbludgeon at gmail.com> wrote:
>
> The problem is with intervals, is that if someone's connection flakes
> out for a minute or two, you end up doing tons of ajax calls that all
> overlap causing wacky behavior. The point of tail recursion is to
> wait for the ajax call to complete, before starting the timer to do a
> new request.
I've written a few ajax page periodic updaters. If the connection flakes
and the ajax request fails, I usually pop up an alert error message so
the user is aware that things are currently broken. Too keep things
simple, I send a query to the server, get back a timestamp. If that
timestamp is newer than the current one in memory, then it refreshes the
entire page. The downside to this is that if someone is actively editing
fields, they will lose their data. To circumvent this problem, I have a
"do not refresh" flag which is set when a user clicks onto any input
box. The flag is unset with events like onBlur or after a timeout period
of keyboard/mouse inactivity so the page can refresh (if necessary) when
idle.
~Rolan
More information about the talk
mailing list