Let's say you are displaying a form populated with data from a db table for a user to edit, and you want to AJAXify(with Prototype). Your backend script does the validation. Suppose they POST it and validation fails, what do you do?
I have experimented with converting a PHP array of error messages (fieldName => errorMessage, etc) into JSON and sending that back, then doing DOM scripting to stick the error messages into some DIVs. Kind of a lot of work, but it's efficient in the sense that you only send data that the front end needs. The other option is to redraw the whole form with the error messages in the DIVs and send back that chunk of HTML. Less efficient in that you are sending back a bunch of bytes that are the same as what was there in the first place, but more efficient in that you re-use more code, and do less client-side acrobatics, than if you return a JSON data structure. Am I being a byte-Nazi? Any thoughts? -- David Mintz http://davidmintz.org/ Just a spoonful of sugar helps the medicine go down In the most delightful way.
_______________________________________________ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php
