-
12 Mar 2012 2:23 PM #1
Ext.Ajax.Request executes the success handler when it fails
Ext.Ajax.Request executes the success handler when it fails
I'm using Sencha Touch 2.0 (release).
Code:Ext.Ajax.request({ url: 'https://somewhere.com/api/404', jsonData: {}, success: function() { console.log('success') } }); // <-- the success handler is executed when the request fails
-
12 Mar 2012 2:25 PM #2
(Oops. The title should read "Ext.Ajax.request".)
-
12 Mar 2012 3:00 PM #3
Inside the onComplete and parseStatus functions of Ext.data.Connection, request.xhr.status is interpreted as success when it is 0, which I believe is incorrect according to the W3C specification.
http://www.w3.org/TR/XMLHttpRequest/#the-status-attribute
-
12 Mar 2012 3:14 PM #4
workaround
workaround
I'm sure there is a reason this was added sometime between PR3 and 2.0 Release, but for now, I'm using this workaround:
Code:Ext.define('Ext.data.Connection.fixed', { override: 'Ext.data.Connection', parseStatus: function(status) { status = status == 1223 ? 204 : status; var success = (status >= 200 && status < 300) || status == 304 /*|| status == 0*/, // <-- 0 is bad! isException = false; if (!success) { switch (status) { case 12002: case 12029: case 12030: case 12031: case 12152: case 13030: isException = true; break; } } return { success: success, isException: isException }; } });
-
14 Mar 2012 9:55 AM #5Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,651
- Vote Rating
- 14
Thank you for the report.
-
16 Mar 2012 3:39 PM #6Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
Ah I think we did this to support the microloader when using native packaging. I'll confer with Jacky to see if we can come up with a better solution
Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
9 Apr 2012 2:29 PM #7Sencha - Sencha Touch Dev Team
- Join Date
- Jul 2009
- Location
- Palo Alto, California
- Posts
- 469
- Vote Rating
- 9
This has been addressed for 2.0.1 release
Sencha Touch Lead Architect
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-2468
in
2.0.


Reply With Quote