Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    972
    Vote Rating
    105
    Daniil is a glorious beacon of light Daniil is a glorious beacon of light Daniil is a glorious beacon of light Daniil is a glorious beacon of light Daniil is a glorious beacon of light Daniil is a glorious beacon of light

      0  

    Default [4.1.0] AjaxProxy Exception listener: operation.getError() returns undefined

    [4.1.0] AjaxProxy Exception listener: operation.getError() returns undefined


    REQUIRED INFORMATION

    Ext version tested:
    • Ext 4.1.0
    Browser versions tested against:
    • IE9
    • Chrome 18
    • FF 12
    DOCTYPE tested against:
    • Any
    Description:
    • I expect to get an Error message within AjaxProxy exception listener using
      Code:
      operation.getError();
      but getting "undefined".
    Steps to reproduce the problem:
    • The AjaxProxy below should process a response like this:
      Code:
      {success: false, message: "Hello! I am the Error."}
      Content-Type of a response is "application/json".
    The result that was expected:
    • I expect to see "Hello! I am the Error." message within an alert box.
    The result that occurs instead:
    • I see the "undefined" message within the alert box.
    Test Case:

    Code:
    Ext.create("Ext.data.Store", {
        model: Ext.define(Ext.id(), {
            extend: "Ext.data.Model",
        }),
        autoLoad: true,
        proxy: {
            type: "ajax",
            url: "/Test/GetData",
            listeners: {
                exception: {
                    fn: function (proxy, response, operation) {
                        alert(operation.getError());
                    }
                }
            }
        }
    });
    A response should be like this:
    Code:
    {success: false, message: "Hello! I am the Error."}
    Content-Type of a response is "application/json".

    HELPFUL INFORMATION

    Debugging already done:

    • I think the problem lies within the proccessResponse function.
    The "success" is true. It comes from Ext.data.Connection which is correct, because the response status is 200. Go ahead to this line:
    Code:
    result = reader.read(me.extractResponseData(response));
    I don't think the reader should read a response if there is "success: false;".

    Nevertheless, result.success becomes false, but result.message is undefined. And this goes to:
    Code:
    operation.setException(result.message);
    Though it looks to be a consequence, the main problem, repeat myself, appears to here
    Code:
    result = reader.read(me.extractResponseData(response));
    processResponse
    Code:
    function (success, operation, request, response, callback, scope) {
        var me = this, reader, result;
        if (success === true) {
            reader = me.getReader();
            reader.applyDefaults = operation.action === "read";
            result = reader.read(me.extractResponseData(response));
            if (result.success !== false) {
                Ext.apply(operation, { response: response, resultSet: result });
                operation.commitRecords(result.records);
                operation.setCompleted();
                operation.setSuccessful();
            } else {
                operation.setException(result.message);
                me.fireEvent("exception", this, response, operation);
            }
        } else {
            me.setException(operation, response);
            me.fireEvent("exception", this, response, operation);
        }
        me.afterRequest(request, success);
        if (typeof callback == "function") {
            callback.call(scope || me, operation);
        }
    };
    Possible fix:
    • not provided
    Operating System:
    • Windows 7 Home Premium

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,120
    Vote Rating
    508
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    There's an option whether to read the response if success is false.

    If you provide a messageProperty it gets read:

    Code:
    Ext.onReady(function() {
        Ext.create("Ext.data.Store", {
            model: Ext.define(Ext.id(), {
                extend: "Ext.data.Model",
            }),
            autoLoad: true,
            proxy: {
                type: "ajax",
                url: "data.json",
                reader: {
                    type: 'json',
                    messageProperty: 'message'
                },
                listeners: {
                    exception: function(proxy, response, operation) {
                        console.log(operation.getError());
                    }
                }
            }
        });
    });
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    972
    Vote Rating
    105
    Daniil is a glorious beacon of light Daniil is a glorious beacon of light Daniil is a glorious beacon of light Daniil is a glorious beacon of light Daniil is a glorious beacon of light Daniil is a glorious beacon of light

      0  

    Default


    Thanks a lot, Evan. I see now that all logic that I need is implemented within Reader.

    I also discovered that I need to set up the "readRecordsOnFailure" option to false. It's true by default and Reader tries to read records even on failure. By the way, I'm a bit surprised why it is "true" by default. I would expect "false".

    Agreed, it is not a bug, I just missed these options trying to find the problem within Proxy.

    Apologize for wasting your time.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar