NYCPHP Meetup

NYPHP.org

[nycphp-talk] AJAX and State

Kenneth Downs ken at secdat.com
Tue Sep 4 08:50:56 EDT 2007


One thing that seems to have gone unsaid in the praise for Ajax is its 
ability to radically transform how we maintain state.

The web server session is our basic mechanism for storing information 
between requests.  But it gets clumsier and clumsier to try to maintain 
complex state across many page requests when you use a session.  
Ingenious minds have put their will to the problem and come up with 
workable systems, but all of them are complicated because of the nature 
of the problem.

That problem, stated here, is simply the problem of tracking what I'll 
call the "context" of a user's session.  Some elements of a session are 
fixed: the user id, the password, a few other things, but almost 
everything that we need to track is always changing.  A basic example: a 
list of search results.  Where do you store it?  When the user hits, 
"NEXT PAGE", how do you know what to do?  If you are using a session, 
what happens if he opens a new window and has two search results sets up 
for two different tables?

Ajax solves this problem neatly by letting you move all state [1] into 
the browser.  This makes sense from an architectural viewpoint because 
we are putting this context information close to where it is needed, the 
UI. 

I've been converting the basic Andromeda UI code over to a completely 
AJAX system [1], and have found my code radically simplified and far 
smoother, due almost entirely to the moving of all state information to 
the browser.  Hurray for Ajax!

[1] Here I'll use "state" to mean the changing context of user requests, 
and assume we are still using the session for User_id and password.

[2] Andromeda is used to make database applications for businesses, we 
don't care in this case about google following our links.


-- 
Kenneth Downs
Secure Data Software, Inc.
www.secdat.com    www.andromeda-project.org
631-689-7200   Fax: 631-689-0527
cell: 631-379-0010




More information about the talk mailing list