Benefits of success property in JSON
I have been using EXT JS 4 for a project. I have read through several of the provided guides but unfortunately haven't found the answer to my question, at least not directly.
I am using JSON returned from a Server without a success property and without a root. It works for the most part but some things are not as "automatic" as I would think they are supposed to be. My question: What are the benefits of having a success property in the JSON? Does it allow things such as loading records into a form easier? The reason I ask this last question is just 1 example of the issues I am having. Once again I was able to get it to work but had to do extra work that I wouldn't have thought necessary.
The server code is using Spring 3.1 to return Domain objects as JSON. Our EXT JS client side will not be the only client to our REST services and hence I don't necessarily want to add a success property.
From practical experience, I find the success property invaluable as there are times when a data related error occurs and I need a practical way to indicate this to the user.
My server-side code adds a structured "error" object to the JSON response if a logical error occurs; generic client code always examines the JSON response status and displays an error message if necessary. This keeps all of the error message creation duties on the server-side and provides a standard, generic mechanism for the client to display user error messages as needed.
Any error messaging always occurs within the success/failure handling code of an Ajax request, so I don't have to worry about when/where to display such a message, is a store finished loading, etc.
Last edited by friend; 19 Dec 2012 at 10:14 AM.
Thanks for the feedback friend.
What I still trying to find out is if it is absolutely needed for EXT JS 4.1.0 to function properly. I am having so many issues with my form and grid. It doesn't make sense to me that I need to do so much work for a framework that is supposed to make life easier.
There is a bit of a learning curve with ExtJS, but the community is pretty good to help out I've found. If you're still having trouble with a component / concept you might post some of your example code and data and folks are often pretty good about giving what you've written a once over (provided you're not posting a Russian novel's worth of code ).
Tags for this Thread