Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add beforerequest event to ajax request in Extjs 4?

how to add beforerequest and requestcomplete event to specific ajax request in Extjs4?

Regards

like image 364
Gihan Lasita Avatar asked Aug 25 '11 23:08

Gihan Lasita


1 Answers

Ext.Ajax.on("beforerequest", function(){
        console.info("beforerequest");
    });
Ext.Ajax.on("requestcomplete", function(){
        console.info("requestcomplete");
    });

Ext.Ajax.request({
    url: 'get-nodes.php',
    success: function(response){
        var text = response.responseText;
        console.info("response");
    }
});

or if you need it in specific cases, try this :

Ext.define('myAjax', {
    extend: 'Ext.data.Connection',
    singleton: true,
    constructor : function(config){
        this.callParent([config]);
        this.on("beforerequest", function(){
            console.info("beforerequest");
        });
        this.on("requestcomplete", function(){
            console.info("requestcomplete");
        });
    }
});

myAjax.request({
    url: 'get-nodes.php',
    success: function(response){
        console.info("response");
    }
});
like image 168
Egy Mohammad Erdin Avatar answered Sep 22 '22 19:09

Egy Mohammad Erdin