如何在Extjs4中将beforerequest和requestcomplete事件添加到特定的ajax请求?
问候
解决方法
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"); } });
或者如果您在特定情况下需要它,请尝试以下方法:
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"); } });