Wednesday, October 31, 2012

JQuery save success/error

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 cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: