ajaxStart / ajaxStop / load Optimization

时间:2014-12-09 22:13:27

标签: javascript jquery ajax optimization

我正在尝试优化我的Ajax代码 - 它很慢而且运行不顺畅。

#first DIV是徽标
#second DIV是一个加载器

我希望在脚本执行Ajax请求时用加载程序替换徽标

$(document).ready(function() {

    $(document).ajaxStart(function(){
        $('#first').hide();
        $('#second').show();
    }).ajaxStop(function(){
        $('#second').hide();
        $('#first').show();
    });

    //Several database requests via .load(), .click(), $(document).on("click") etc. here
    //Everytime I call them, I want this replacement to be done quickly.

});

我应该预加载徽标/装载机吗?

0 个答案:

没有答案
相关问题