Altering the URL on all ajax-calls from ExtJS

extjs, extjs4.1, javascript

Solution

This is what we do:

Ext.data.Connection.override({
    //add an extra parameter to the request to denote that ext ajax is sending it
    request: function(options){
        var me = this;
        if(!options.params)
            options.params = {};
        options.params.ext_request = true;

        return me.callOverridden(arguments);
    }
});

Connection is the class that Ext.Ajax inherits from.

Problem

I am using Ext.Ajax.request() in lots of places in my ExtJS Application. Is there a way to have a function run just before the Ajax-call is made, that can alter the URL just before it is sent? I would like to add an extra query-string to all of my Ajax requests dynamically. I do not want to go and edit all my Ajax-calls manually.

Original source