Threaded View
-
19 Nov 2012 5:05 AM #1
Sencha Touch 2.1 marks Ajax JSON response as failed if server returns empty array
Sencha Touch 2.1 marks Ajax JSON response as failed if server returns empty array
In Ext.data.reader.Reader nullResultSet is defined like this:
The problem is that the Ext.data.reader.Reader#readRecords has the following code:Code:// Empty ResultSet to return when response is falsy (null|undefined|empty string) nullResultSet: new Ext.data.ResultSet({ total : 0, count : 0, records: [], success: false })
that causes nullResultSet to be returned not only in cases specified above, but also for empty arrays. Because nullResultSet has success flag set to false, it causes the whole response to be incorrectly marked as failed.Code:if (isArray && !data.length) { return me.nullResultSet; }
BTW. I can fix it myself, but currently there's no way to contribute to Sencha Touch, right? Any plans to use GitHub or something similar for hosting Sencha Touch code?
Here's how I fixed it (touch/src/data/reader/Reader.js)
Code:if (isArray && !data.length) { - return me.nullResultSet; + return new Ext.data.ResultSet({ + total : 0, + count : 0, + records: [], + success: true + }); }
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote