Reputation: 3211
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();
});
Upvotes: 2
Views: 6982
Reputation: 2962
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..
Upvotes: 3
Reputation: 14827
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();
Upvotes: 7