hereiam
hereiam

Reputation: 836

Extjs - passing specific params thru ajax to another script

I have a chart located in a panel. I want to pass the title of the panel to a php script using ajax. I already use ajax proxy for my store. I would like to know the title of the panel so that I can query for the correct data, for example. Here's what I've done so far.

var store = Ext.create('Ext.data.JsonStore', {
    fields: ['project', 'accepted', 'rejected', 'deleted', 'undefined'],
    proxy: {
        type: 'ajax',
        url: 'generate_proj.php',
        extraParams: {foo: this.idname},
        reader: {
            type: 'json'
        }
    },
    autoLoad: true,
    listeners:  { 
        load: function(obj,records) {
            var text = Ext.decode(obj.responseText);
            console.log(this.idname);
            Ext.each(records,function(rec) {});
        }
    }
});  

In my php script I use $value = $_GET['foo'];.

I'm sure I'm close but I can't find any examples or documentation about how to take better advantage of params. Any help or ideas?

Upvotes: 0

Views: 1197

Answers (1)

Ruan Mendes
Ruan Mendes

Reputation: 92274

extraparams should be extraParams, camel cased. http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.proxy.Server-cfg-extraParams though there is a comment on their documentation saying that it doesn't work.

A workaround is to listen to the beforeload event and change the params from there http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.AbstractStore-event-beforeload

listeners:  {
    scope: this 
    beforeload: function(store, operation) {
        operation.params.foo = this.idname;
    }
}

Upvotes: 1

Related Questions