Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript $(document).ready()在head.ready()中调用时未激发_Javascript_Jquery_Internet Explorer 11_Document Ready_Head.js - Fatal编程技术网

Javascript $(document).ready()在head.ready()中调用时未激发

Javascript $(document).ready()在head.ready()中调用时未激发,javascript,jquery,internet-explorer-11,document-ready,head.js,Javascript,Jquery,Internet Explorer 11,Document Ready,Head.js,我在使用jQuery$(document.ready和headjs framework v1.0.3时遇到了一个问题,该版本具有head.ready功能,仅在Internet Explorer上使用(版本11,我无法在旧版本上试用),而且十年中只能使用一次 就在之前,我有: head.load('//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js',function() { head.load('//ajax.googl

我在使用jQuery
$(document.ready
和headjs framework v1.0.3时遇到了一个问题,该版本具有head.ready功能,仅在Internet Explorer上使用(版本11,我无法在旧版本上试用),而且十年中只能使用一次

就在
之前,我有:

head.load('//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js',function() {
    head.load('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js');
    head.ready(function() {
        $(document).ready(function() {
            $('.class').show();
        });
    });
});
有时,不会触发$(document).ready事件。 它在Chrome和Firefox上运行良好

$(window).load doesn't work better.
我试图将
head.ready()
放出来,但没有成功:

head.load('//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js',function() {
    head.load('//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js');
});
head.ready(function() {
    $(document).ready(function() {
        $('.class').show();
    });
});
我使用
head.ready
而不是
$(document.ready
)找到了一个解决方案,但是我不能使用这个解决方案,因为
head.ready(function(){…})中的部分
来自与不使用headjs的平台共享的代码


有人遇到过这个问题或有解决办法吗?

我猜这是一个竞赛条件。您可能希望在head ready中检查文档是否已经处于就绪状态,因为不会触发
document.ready

head.ready(function() {
  var readyfunc = function(){
     $('.class').show();
  };

  if (document.readyState === 'complete'){
    readyfunc();
  }else{
    $(document).ready(function() {
      readyfunc();
    });
  }
}

查看是否有效。

document.ready与动态加载内容无关。它只处理初始页面加载。什么是
head
load()
替换内部html,不是加载脚本的正确方法。还有,为什么不能使用脚本标签呢?我加载了50次页面,没有问题,所以我想这个解决方案修复了这个错误。谢谢