javascript - Altering the URL on all ajax-calls from ExtJS - Stack Overflow

I am using Ext.Ajax.request() in lots of places in my ExtJS Application.Is there a way to have a functi

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.

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.

Share asked Jul 24, 2013 at 20:18 Daniele TestaDaniele Testa 1,6773 gold badges18 silver badges35 bronze badges 2
  • There should be a central AJAX handler in EXT that you could extend or patch into (you get the source code). I'm not sure where, but that's a start. – Diodeus - James MacFarlane Commented Jul 24, 2013 at 20:20
  • Yeah, that's what I was thinking. Was hopeing for some code though ;) – Daniele Testa Commented Jul 24, 2013 at 20:26
Add a ment  | 

2 Answers 2

Reset to default 4

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.

Ext.Ajax has a beforequest event that fires before any request happens:

Ext.Ajax.on('beforerequest', function(conn, options, eOpts) {
    console.log('The options parameter contains the options');
    console.log(' going to the request method');
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744935163a4601975.html

相关推荐

  • javascript - Altering the URL on all ajax-calls from ExtJS - Stack Overflow

    I am using Ext.Ajax.request() in lots of places in my ExtJS Application.Is there a way to have a functi

    1天前
    80

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信