View Full Version : Error in JSON Reader on success false without root property

3 Aug 2011, 1:33 AM

I'm trying to load data within a store via an AJAX proxy. The reader is configured to expect a success property with the value 'success' and a root property with the value 'value'. The Server response looks like this:

"message":"Error message ...",

The operation fails in the following line in the Ext.data.reader.Reader with a 'obj.value is undefined':

var root = Ext.isArray(data) ? data : me.getRoot(data),

The implementation expects a root element even if the server responds with success=false. In my opinion it should not be necessary to define a root element on fail. Why is this, or am I seeing something completly wrong?

5 Aug 2011, 9:07 PM
I tend to agree.

However, the reasoning behind it might be that in some cases the server might return data also for unsuccessful requests.
Let's say an UPDATE request partially failed, then the server may want to return the current state of the object(s) in order for the client to show data that is in sync with the server (without the client having to do an explicit refresh).

I do support the behavior that reader does not fail silently for successful requests if the root node is missing. I think it would make debugging a lot more difficult especially for beginners.

I still totally see your point though.

Maybe you should file a bug report (http://www.sencha.com/forum/showthread.php?138165-How-to-report-a-bug).

7 Aug 2011, 5:56 AM
Try do not use proxy cause in this case it is JSONP and you must to return
answer with callback function.

Answer from server must be like this

callback1({ "success":false, "message":"Error message ...",})
Callback must be send by client.
Try to find out what else property send to server it shoud be name of callback function between them.

If you want to avoid of this not easy way DO NOT USE PROXY.

Use this

9 Aug 2011, 5:49 AM
huh! This is Ext4!

And yes, if you want to do JSONP you should use the JSONP proxy. However, if you want standard AJAX you should use the AJAX proxy.

9 Aug 2011, 11:40 PM

thanks for the answers. A colleague of mine has created a custom Ajax proxy which uses a custom Connection. This enables us to handle errors in the Connection before the Reader is called.