[nycphp-talk] AJAX and State
Steve Manes
smanes at magpie.com
Wed Sep 5 19:47:11 EDT 2007
tedd wrote:
> Now, what I am asking is not how ajax communication with the server can
> be used, but rather is there anything beyond that which ajax can provide?
>
> Another way of asking this question is, "Besides not triggering a
> refresh, what can ajax do that php can not?"
You're right: nothing. But just focusing on the get/post mechanics as a
baseline for comparison is kinda reducing the question to, "is there
anything client/server can do that client/server can't do?"
Ajax is just a tool. My table saw cuts wood one way, my compound miter
saw another, my radial arm saw another. Technically, they can all do
the same cuts. It's just a lot nicer (and safer) to use a table saw to
rip panels and an SCMS to crosscut long lumber. And technically most of
what they can do can be done with a manual carpenter's saw and a bottle
of glucosomine.
Here's an example where Ajax is the better tool. I'm building a medical
application which has a desktop containing seven collapsible DIVs. Each
of those DIVs can also have at least two states: view and edit. Some
have three, with a result list (like a list of current insurance
policies). That's the way the client wanted it.
Necessarily, there are a lot of queries going on to populate all the
DIVs on that page: patient demographic info, insurance info, guarantor
info, family relations info, a list of historical referrals,
appointments, patient transportation, etc. So repopulating that page
sucks the air out of the database. If I correct a start date for an
insurance policy do I really want to repopulate that entire desktop
page? Heck no.
The better solution is to submit just the form that matters and update
just those DIVs where that update has data relevance. Mostly it's two
just queries instead of a dozen: put_foo and get_foo, with Ajax
arbitrating which display elements get updated.
More information about the talk
mailing list