Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-2468 in a recent build.
  1. #1
    Ext Premium Member
    Join Date
    Sep 2009
    Posts
    48
    Vote Rating
    1
    yoh.suzuki is on a distinguished road

      0  

    Default 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

  2. #2
    Ext Premium Member
    Join Date
    Sep 2009
    Posts
    48
    Vote Rating
    1
    yoh.suzuki is on a distinguished road

      0  

    Default


    (Oops. The title should read "Ext.Ajax.request".)

  3. #3
    Ext Premium Member
    Join Date
    Sep 2009
    Posts
    48
    Vote Rating
    1
    yoh.suzuki is on a distinguished road

      0  

    Default


    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

  4. #4
    Ext Premium Member
    Join Date
    Sep 2009
    Posts
    48
    Vote Rating
    1
    yoh.suzuki is on a distinguished road

      0  

    Default 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
            };
        }
    });

  5. #5
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    21
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Thank you for the report.

    Sencha Inc

    Jamie Avins

    @jamieavins

  6. #6
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    7
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    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

  7. #7
    Sencha - Sencha Touch Dev Team Jacky Nguyen's Avatar
    Join Date
    Jul 2009
    Location
    Palo Alto, California
    Posts
    469
    Vote Rating
    14
    Jacky Nguyen has a spectacular aura about Jacky Nguyen has a spectacular aura about

      0  

    Default


    This has been addressed for 2.0.1 release
    Sencha Touch Lead Architect