在我的sencha应用程序中,当app遇到ajax请求时我想添加加载掩码,请求完成后我需要删除加载掩码。
我试过下面的代码,但是它不适合我
var mask = new Ext.LoadMask(Ext.getBody(), {msg:"Loading..."});
Ext.Ajax.on('beforerequest', function(){
mask.show();
});
Ext.Ajax.on('requestcomplete', function(){
mask.hide();
});
答案 0 :(得分:7)
要显示加载掩码,您可以使用:
Ext.Viewport.mask({ xtype: 'loadmask' });
并在您的Ajax请求的成功函数中隐藏加载掩码:
Ext.Viewport.unmask();
答案 1 :(得分:2)
很容易尝试这些
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
成功功能后添加加载掩码..