Michal Charemza wrote: > > - So would I need to "route" based on the X-Requested-With header, to > a new action: say 'PostCommentsAjax' action? How would I do this?
Almost correct - you'd use a route to alter the output type, not action. You can see how this is done in the sample app: Route (line 17): http://trac.agavi.org/browser/branches/1.0/samples/app/config/routing.xml Output type (json) http://trac.agavi.org/browser/branches/1.0/samples/app/config/output_types.xml > - Should this PostCommentsAjax action be a subclass of > PostCommentsAction? I would like to avoid copy/pasting the code from > PostCommentsAction. > Actions should never know anything about the output type. Just use the same PostCommentsAction as for HTML output type. The only thing you need to add is executeJson() in your view. Remember, only the View part in MVC is different here. > good idea to actually return a JSON object, with the html as one of > the values, as I might want other parameters passed back, like > "success:true" or something. I'd return JSON telling the result code (e.g. "success" or "error") and validation errors (fields and error messages, you can easily get them from the validation manager). You can then easily highlight erroneous fields and their labels and inject error messages next to the fields and/or form. -veikko -- Veikko Mäkinen [email protected] 044 5910 413 http://blog.veikko.fi _______________________________________________ users mailing list [email protected] http://lists.agavi.org/mailman/listinfo/users
