开发者

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

how to add beforerequest and requestcomplete event to spe开发者_如何学Ccific ajax request in Extjs4?

Regards


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");
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜