Results 1 to 6 of 6

Thread: Prevent store to mark records as saved on empty (0 byte) server response

  1. #1
    Sencha User
    Join Date
    Dec 2016
    Location
    Pinar del Rio, Cuba
    Posts
    9

    Default Prevent store to mark records as saved on empty (0 byte) server response

    What about the _unpredictable_ cases where the server returns an empty response, cero byte I mean? How can I prevent a store to mark records as saved after calling sync() and receiving an empty but non error response from the server? The only solution I can imagine but have not tested it yet, is to hook into global Ext.Ajax and try somehow to stop the event chain that ends up with the store thinking everything is OK and marking records as saved, synced. What would be the best approach?
    Thanks a lot for your time.

  2. #2
    Sencha - Support Team bjdurham85's Avatar
    Join Date
    Mar 2014
    Posts
    962
    Answers
    55

    Default

    Hi--,

    Is it throwing a non-200 response and/or just 0 bytes?

    Bryan

  3. #3
    Sencha User
    Join Date
    Dec 2016
    Location
    Pinar del Rio, Cuba
    Posts
    9

    Default

    Hi Bryan, nope, it is a 200, non error response with 0 bytes!

  4. #4
    Sencha - Support Team bjdurham85's Avatar
    Join Date
    Mar 2014
    Posts
    962
    Answers
    55

    Default

    I can't quite tell from your initial post how you've defined the store/events. Do you have (or can you put together) a Fiddle demonstrating your specific scenario so I can take a look?

    **Also, does the 0 bytes from your server indicate an error and/or does it normally return a result (A correct/empty response would be useful in your Fiddle)?

    Bryan

  5. #5
    Sencha User
    Join Date
    Dec 2016
    Location
    Pinar del Rio, Cuba
    Posts
    9

    Default

    Thanks for your time Bryan. Mine is a fundamentals question, then I thought there was no need to post code. You can test this case targeting in your app a properly hosted php script for instance, which produces no output. Then you will see what I mean. The cero byte response mostly happens due to programmer mistakes in server side code, then its unpredictable. But I think Ext should complain about those responses and of course, don't eat that "bad apple". Even when you specify successProperty and totalProperty, which of course are never present in a cero byte response, the records are marked as saved, synced.
    Thanks again.

  6. #6
    Sencha Premium Member richardvd's Avatar
    Join Date
    Jun 2011
    Location
    NL
    Posts
    253
    Answers
    22

    Default

    It is the default behaviour of Ext.data.reader.Reader to interpret an empty HTTP 200 response as successful. The value of the private nullResultSet config determines what will be returned upon a falsy response (null|undefined|empty string).

    Add this to your reader config to get the opposite behaviour:

    Code:
    ​nullResultSet: Ext.create('Ext.data.ResultSet', {
        total  : 0,
        count  : 0,
        records: [],
        success: false 
    })

Similar Threads

  1. Replies: 3
    Last Post: 27 Feb 2013, 1:39 AM
  2. Getting store saved records on server
    By gfevrier in forum Ext: Discussion
    Replies: 4
    Last Post: 21 Nov 2012, 9:31 AM
  3. ext-record-# on list for empty server response
    By runfaj in forum Sencha Touch 2.x: Q&A
    Replies: 3
    Last Post: 28 Jun 2012, 7:18 AM
  4. Replies: 5
    Last Post: 8 Sep 2011, 12:48 AM
  5. DynamicGridPanel is empty although Json response gives records
    By natts_82 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 28 Dec 2009, 10:53 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •