jquery - css 动画在脚本加载时被挂起

标签 jquery css animation css-animations getscript

我正在使用 jquery 的 $.getScript block 来缓存 javascript 文件。

这是使用 $.when

的代码
function loadResources() {
    $.ajaxSetup({
        cache:true
    });
    $("#animate").removeClass("hideBlock");

    $.when(
        $.getScript( "http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js" ),
        $.getScript( "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js" ),
        $.getScript( "http://ajax.googleapis.com/ajax/libs/dojo/1.10.0/dojo/dojo.js" ),
        $.getScript( "http://ajax.googleapis.com/ajax/libs/ext-core/3.1.0/ext-core.js" ),
        $.getScript( "http://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.js" ),
        $.getScript( "http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js" ),
        $.getScript( "http://ajax.googleapis.com/ajax/libs/mootools/1.5.1/mootools-yui-compressed.js" ),
        $.getScript( "http://cdn.kendostatic.com/2013.1.319/js/kendo.all.min.js" ),
        $.getScript( "http://cdn.kendostatic.com/2013.1.319/js/kendo.aspnetmvc.min.js" ),
        $.getScript( "http://cdn.kendostatic.com/2014.2.903/js/kendo.all.min.js" ),
        $.getScript( "http://cdn.kendostatic.com/2014.2.903/js/kendo.all.min.js" ),
        $.getScript( "http://demos.telerik.com/kendo-ui/content/shared/js/kendo-dojo.js" ),
        $.getScript( "http://demos.telerik.com/kendo-ui/content/shared/js/console.js" ),
        $.getScript( "http://demos.telerik.com/kendo-ui/content/shared/js/prettify.js" ),
        $.getScript( "http://demos.telerik.com/kendo-ui/content/shared/inspector/inspector.js" ),
        $.Deferred(function( deferred ){
            $( deferred.resolve );
        })
    ).done(function(){
        $("#animate").addClass("hideBlock");
        $.ajaxSetup({
            cache:false
        });
    });
}

HTML:

<a id="trigger" href="javascript:void(0)">Click to load</a>
<div id="animate" class="hideBlock"></div>

在我的 html 中,我使用了 css3 动画。只要脚本正在加载,就应该显示此动画。

JSFIDDLE:http://jsfiddle.net/nL1ubLyt/3/

当使用 $.getScript 加载脚本时,加载动画会在 Firefox 中挂起。在 chrome 中工作正常。我不认为这是 $.getScript 的问题。但非常感谢任何帮助。

最佳答案

你需要打开 async : true ,类似下面的内容

$.ajaxSetup({async: true});

关于jquery - css 动画在脚本加载时被挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25843842/

相关文章:

javascript - Jquery 时间轴插件

javascript - 模态内可扩展文本的 CSS 问题

css - 为什么我的 CSS 网格不能在 IE 11 中正确呈现?

javascript - 如何更改通过 XMLHttpRequest 添加的第一个 LI 值的颜色?

c# - 如何在第一个循环 C# 后停止 PictureBox GIF 动画?

javascript - 多个元素上的 jQuery 动画,单个动画线程/计时器还是多个?

android - ListView 动画淡出然后添加新行

javascript - 使用 jQuery 仅更新同一 div 类中的一个元素

javascript - 如何为页面中的所有元素添加多个onclick事件

javascript - 使用 jQuery 将选定行从一个表复制到另一个表