简体   繁体   English

Bootstrap按钮的“加载”动画在最后工作

[英]Bootstrap button “loading” animation works at the end

I have a button that calls an Ajax function and show users' info in some textarea 我有一个调用Ajax函数并在某些文本区域中显示用户信息的按钮

HTML: HTML:

<button id="btnUsers" class="btn btn-primary pull-left btn-lg" onclick='navUsers.getUsers();' data-loading-text="<i class='fa fa-spinner fa-spin '></i> Processing Order">  Get Users   </button>
<textarea id="resultUsers" name="resultUsers" cols="100" rows="18" class="form-control"></textarea>

JS: JS:

var navUsers = new function (){ 
    this.getUsers = function(){
       $("#btnUsers").button('loading');
       $.ajax({ //ajax stuff, shows users in the textarea })
    };
};

The problem is: the button's 'loading' animation only starts after the Ajax stuff is finished, not before. 问题是:按钮的“加载”动画仅 Ajax内容完成后才开始,而不是在之后。 I've tried some 'modal' bootstrap div for showing mensajes while loading users and same happens. 我尝试了一些“模态”引导程序div,用于在加载用户时显示mensajes,并且发生了同样的情况。 Also I've tried the beforesend option in Ajax, same results. 我也尝试过Ajax中的beforesend选项,结果相同。

var navUsers = new function (){ 
    this.getUsers = function(){
       $("#btnUsers").button('loading');
       setTimeout(function() {
          $.ajax({ 
            //ajax stuff,
            success:function(){
            $("#btnUsers").button('reset');
          }
       })
    }, 1000);

    };
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM