I did it the following way: An action returns the rendered view if there were errors while saving the data, otherwise it returns xml that contains info including what page element should be refreshed etc.
JS code: # make form "ajax" var makeAjaxForm = function(){ $('form',this).ajaxForm({ //onActionSubmit will be fired when the response is received success: onActionSubmit }); }; #reloads form on error or sends response xml to processing var onActionSubmit = function(responseText) { //if the response is xml if(jQuery.isXMLDoc(responseText)) { //process it, reload some elements etc processXML(responseText); //hide form hideActionBox(); } else { //load the rendered view into #reqAction .content (the form container) $('#reqAction .content').html(responseText); //make the form ajax again makeAjaxForm(); } }; Action wrote: > I have a blog-like page that contains a post, comments, and a new > comment form. I want the new comment form to submit using ajax (but > also work if the user has js disabled) and have the newly added > comment appear in the comments list. > > Currently, I'm using the jQuery Form Plugin to submit the form: > http://www.malsup.com/jquery/form/. I don't want to use the prototype > helper due to the inline code it generates. > > So far, the form submission works, but all that is happening is the > data being saved. The view does not show any validation error messages > defined in the model and does not show the new comment (I have to > refresh the page to get the comment to show up and the validation > error messages never show up). > > How can I fix this so the form not only submits using ajax, but the > form data is also rendered in the view if saved, or the appropriate > validation error messages appear? I've done some searching and I think > I'm supposed to use the requestHandler component. However, I don't > really understand how I am supposed to use it in this situation (the > manual documentation is pretty vague). > > Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---