NYCPHP Meetup

NYPHP.org

[nycphp-talk] Client vs. Server programming

Ajai Khattri ajai at bitblit.net
Thu Sep 21 18:02:25 EDT 2006


LK wrote:
> In the JavaScript/AJAX framework the form and
> the entire page is available thru the DOM, and I just have a simple query.php
> script running on the server to execute queries and send back the result. I
> construct the query and AJAX it over to the query.php. If a record with the
> same username is found, I alert("...") the user to try it again. The original
> form remains on the screen without change. The deal is done.


And so if javaScript is switched off there is no validation then? You 
will *always* need server-side validation to fall back on...

> Not so with the server side programming. The form is submitted to a
> process_form.php. Then, if the username already exists in the database, the
> script has to rebuild the original form with the previous values filled in by
> copying user inputs from the $_POST array back into the HTML for *each* input
> field with <?php echo $_POST[] ?>, not to mention session state and other
> housekeeping. That seems like a lot of work to implement something so simple.

Yes it involves work (and we make it look so easy ;-)

> So what are the advantages of server programming? What what am I missing? 

Its not an either-or kind of question - ideally you would want to do 
both (especially where validation is concerned).

Its all very well using AJAX but you have to remember that an AJAX call 
may still end up calling a server-side resource at some point. Also, how 
would you handle session data? Yeah, you could do it on the client but 
that's not efficient in terms of bandwidth and also not good for 
scalability.



-- 
A



More information about the talk mailing list