in both cases return json value and have keys eg. "success" (true/false) and "data". If "success" == true, just "print" data, if "success" == false, than use data as json, and decode that string and print validation errors, or generate string in controller for errors and print it..understand ? -- Lep pozdrav, Tilen Majerle http://majerle.eu
2012/10/31 Jeremy Burns <[email protected]> > Not an expert at jQuery, but getting there. > > I'm submitting data to a controller function that saves a record via ajax. > If the save works, I'm rendering an element, which then appears back in the > ajax form as html ready to be placed into a dom element. All good - that > works fine. But if the save fails I want to return an array that includes > the validation errors - that really ought to be json. So on success I want > html, on error I want json - and I can't have both. > > How do I either (i) render the element but have it returned as json (and > ideally tack in a 'success' key that I can check in the jQuery) or (ii) > otherwise determine the success/error state when html has been returned to > the jQuery? > > -- > Like Us on FaceBook https://www.facebook.com/CakePHP > Find us on Twitter http://twitter.com/CakePHP > > --- > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > Visit this group at http://groups.google.com/group/cake-php?hl=en. > > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php?hl=en.
