When ever app does ajax request i want to add load mask

醉酒当歌 提交于 2019-12-22 17:29:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!