问题
In my sencha application, When ever app does ajax request i want to add load mask and after request complete i need to remove load mask.
I tried below code but, its not working for me
var mask = new Ext.LoadMask(Ext.getBody(), {msg:"Loading..."});
Ext.Ajax.on('beforerequest', function(){
mask.show();
});
Ext.Ajax.on('requestcomplete', function(){
mask.hide();
});
回答1:
To show load mask you can use:
Ext.Viewport.mask({ xtype: 'loadmask' });
And hide the load mask inside the success function of your Ajax request:
Ext.Viewport.unmask();
回答2:
It is very easy Try these
Ext.Ajax.request({
method:'GET',
contentType:'application/json; charset=utf-8',
dataType:'json',
url:'http://..................Login',
disableCaching: false,
withCredentials: true,
useDefaultXhrHeader: false,
callbackKey: 'callback',
params: {
xyz:.......
},
success:function(response){
console.log(response);
var res = response.responseText;
var jsonarr = Ext.decode(response.responseText);
console.log(jsonarr);
var myres = jsonarr[0].Result;
console.log(myres);
Ext.Viewport.setMasked(false); //hide the mask loaded ...
Ext.Viewport.setActiveItem({xtype:'dom_flightlist'});
}//end of success fn
}); //end of AJAX Request
After The Success Function Add the Load Mask..
来源:https://stackoverflow.com/questions/15677860/when-ever-app-does-ajax-request-i-want-to-add-load-mask