1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    2
    Vote Rating
    0
    pbornheimer is on a distinguished road

      0  

    Question Unanswered: Error in JSON Reader on success false without root property

    Unanswered: Error in JSON Reader on success false without root property


    Hi,

    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:

    Code:
    {
      "success":false,
      "message":"Error message ...",
    }
    The operation fails in the following line in the Ext.data.reader.Reader with a 'obj.value is undefined':

    Code:
    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?

  2. #2
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Vote Rating
    14
    Answers
    26
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    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.

  3. #3
    Sencha User Mycoding's Avatar
    Join Date
    May 2010
    Location
    Russia, Volgograd
    Posts
    460
    Vote Rating
    0
    Mycoding is on a distinguished road

      0  

    Default


    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
    Code:
    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
    http://dev.sencha.com/deploy/ext-3.4...data.JsonStore

  4. #4
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Vote Rating
    14
    Answers
    26
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    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.

  5. #5
    Sencha User
    Join Date
    Aug 2011
    Posts
    2
    Vote Rating
    0
    pbornheimer is on a distinguished road

      0  

    Talking


    Hi,

    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.

Thread Participants: 2

Tags for this Thread