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

后端 未结 1 2038
别跟我提以往
别跟我提以往 2021-02-09 13:39

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

Regards

相关标签:
1条回答
  • 2021-02-09 14:12
    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 讨论(0)
提交回复
热议问题