1. #1
    Sencha User eldiego34's Avatar
    Join Date
    Jul 2010
    Location
    Buenos Aires, Argentina
    Posts
    20
    Vote Rating
    0
    eldiego34 is on a distinguished road

      0  

    Default Ajax Proxy/Json Store

    Ajax Proxy/Json Store


    Hi all, i just want to know if there is a "failure" option on those components like in Ajax Request, to handle a bad response. Because i don't have any way to notify this.

    Saludo.

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,065
    Vote Rating
    659
    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


    They do, however the event isn't added in the constructor so I'll need to add that. It will be part of the next release. The event will be 'exception' on the proxy.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User eldiego34's Avatar
    Join Date
    Jul 2010
    Location
    Buenos Aires, Argentina
    Posts
    20
    Vote Rating
    0
    eldiego34 is on a distinguished road

      0  

    Default


    We solve this problem partially until the new release of sencha. Here is the code if anyone is interested.
    Code:
            this.ds = new Ext.data.JsonStore({
                model: 'mtx.smap.FFForm',
                proxy: new Ext.data.AjaxProxy({
                    url: '../srv/smap.json',
                    reader: new Ext.data.JsonReader({
                        model: 'mtx.smap.FFForm',
                        root: 'FF',
                        getResponseData: function(response) {
                            try{
                                var data = Ext.decode(response.responseText);
                            }catch(err){
                                console.error('Invalid Response');//TODO: Manage invalid request.                            
                            }
                            if (!data) {
                                throw {message: 'Ext.data.JsonReader.read: Json object not found'};
                            }
                            return data;
                        }
                    }),
                    actionMethods: {read: 'POST'},
                    writer: new Ext.data.JsonWriter({root: ''}), //avoid passing extra records:[] into the requestBody
                    //hack to get onload event!
                    afterRequest: function(){
                        me.fireEvent('dataloadedFF');
                    },
                    doRequest: function(operation, callback, scope) {
                        var writer  = this.getWriter(),
                            request = writer.write(this.buildRequest(operation, callback, scope));
                        Ext.apply(request, {
                            scope   : this,
                            callback : this.createRequestCallback(request, operation, callback, scope),
                            success: function(response, opts) {
                              //Ajax Request Ok
                            },
                            failure: function(response, opts){
                                console.error('ajax request failed');//TODO: Manage request failure.
                            },
                            method  : this.getMethod(request)
                        });
                        Ext.Ajax.request(request);
                        return request;
                    }
                })
    
            });
    Saludo.

Similar Threads

  1. Change Store Proxy URL without Creating New Store
    By rkdeiss in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 13 Apr 2010, 11:16 AM
  2. Load JSON to store without Proxy
    By mackenda in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 29 Jan 2010, 12:03 PM
  3. Problem with proxy ajax call
    By mysticav in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 4 Dec 2008, 12:10 PM
  4. is data proxy is the same as ajax?
    By ratno in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 24 Nov 2008, 8:35 AM

Thread Participants: 1