You can use options with the form plugin. This might get you going in the right direction:
$('#addCommentForm').ajaxForm({ beforeSubmit: myValidationFn, success: mySuccessFn, error: myErrorFn }); function myValidationFn(formData, $form, opts) { for (var i=0; i < formData.length; i++) { if (!formData[i].value) { alert('All fields are required!'); return false; } } } function mySuccessFn(data, status) { // add response to comment list $('#comments').append(data); } function myErrorFn(xhr, status, err) { alert("Error submitting form: " + err); } On Nov 15, 2007 6:54 PM, Action <[EMAIL PROTECTED]> wrote: > > I was wondering if any of you jQuery + CakePHP users could help me out > here... > > 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 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/. > > 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? > > Thanks. >