Threaded View

  1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    118
    Answers
    3
    Vote Rating
    3
    clifficious is on a distinguished road

      0  

    Default Answered: data.connection custom request object

    Answered: data.connection custom request object


    Hi,

    I have several Ajax.requests in my application. Some options are the same and some are dynamically added. Now I was trying to extend a class, so that the fixed options are always set. But it gives me errors when applying the following simplified code.

    Code:
    Ext.define('My.own.Options', {    
        extend: 'Object',
        
        headers: {
            'Authorization' : 'some Text',
            'Accept-Language' : 'some more Text'
        },
        
    });
    When I then use this class like
    Code:
    Ext.Ajax.request(Ext.create('My.own.Options',{            
         method: 'GET',
         url: someURL,
         success: function(response) {
              do something here...
                    }
         },
         failure: function() {
              do something else here
         }
    }));
    The error is Uncaught TypeError: Cannot call method 'indexOf' of null

    Am I missing something? Thanks for any hints!

  2. You didn't specify a version, so a line number isn't helpful.

    Anyway, the likelihood is that you're not passing a url in. By default, a class won't do anything in the constructor, so anything you're passing in is just ignored.

    Code:
    Ext.define('Overkill', {
        someDefault: 'foo',
        
        constructor: function(cfg){
            Ext.apply(this, cfg);
            this.callParent();
        }
    })
    
    Ext.onReady(function() {
    
        Ext.Ajax.request(new Overkill({
            url: 'bar'
        }))
    
    });
    However as I said above, creating a class instance is overkill, you should just have some kind of wrapper around Ajax that applies your defaults.

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