Steve, How you handle the server response is entirely up to you of course. Personally, I like to use json and do something like this:
success: function(json) { if (json.error) { // display error alert(json.error); } else { // process response where json.data is // something like "Thanks for your comment." $('#myTargetDiv').append(json.data); } } But if your response contains substantial markup then json isn't a good fit. You need to establish a protocol that is straight-forward but can scale for your application/website. Mike On 8/30/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote: > > Hi mike, > > First and foremost, thanks for your reply! > > As for the validation, should I return a string such as 'errors' and > eval() it in my success callback? I'm not entirely sure how to let js > know that the server deemed something in the form as a booboo. > > Thanks again. > > - sf > > Sent from my iPhone > > On Aug 30, 2007, at 8:04 AM, "Mike Alsup" <[EMAIL PROTECTED]> wrote: > > > > > Steve, > > > > If you need that kind of control over the reset then I suggest you use > > the resetForm function rather than the resetForm option property. In > > your success handler, once you've determined there is no logical error > > you, can simply invoke: > > > > $('#myForm').resetForm(); > > > > Mike > > > > > > On 8/29/07, Steve Finkelstein <[EMAIL PROTECTED]> wrote: > >> > >> Hi all, > >> > >> Is there a way I can stop resetForm: true from hitting when I deem > >> something is invalid via server-side validation? For example, here's > >> my ajaxForm object: > >> > >> $('#form2').ajaxForm( > >> { > >> target: '#container', > >> type: 'post', > >> resetForm: true, > >> } > >> ); > >> > >> And on the server-side I have a very rudimentary validation: > >> > >> if($error_message) > >> { > >> echo $error_message; > >> exit; > >> } > >> > >> Is there anyway to tell ajaxForm when there is a logical error so > >> that > >> success: and resetForm: are not executed. I understand those > >> parameters are there for successful AJAX responses, not logical > >> errors. I'm just not sure how to stop the form from resetting when I > >> have logical errors, however I do want this functionality to exist > >> for > >> the form is indeed error free. > >> > >> Thank you, > >> > >> - sf > >> > >> >