Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.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 使用Ajax获取页面加载进度_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript 使用Ajax获取页面加载进度

Javascript 使用Ajax获取页面加载进度,javascript,jquery,ajax,Javascript,Jquery,Ajax,嗯,我不熟悉Ajax和JQuery,我很难编译它。我正在尝试使用ajax导航和popstate检索前后导航加载URL。下面的代码运行得很好,但我的问题是在使用链接时集成我试图加载的页面的进度指示器 jqueryajax测试 paceOptions={ ajax:true,//禁用 文档:true,//已禁用 eventLag:true,//已禁用 要素:{ 选择器:['#呈现我'] } }; 代码中的问题是pace的脚本源代码、pace的css源代码以及html元素的正确放置 我试图在你的脚本

嗯,我不熟悉Ajax和JQuery,我很难编译它。我正在尝试使用ajax导航和popstate检索前后导航加载URL。下面的代码运行得很好,但我的问题是在使用链接时集成我试图加载的页面的进度指示器


jqueryajax测试
paceOptions={
ajax:true,//禁用
文档:true,//已禁用
eventLag:true,//已禁用
要素:{
选择器:['#呈现我']
}
};

代码中的问题是pace的脚本源代码、pace的css源代码以及html元素的正确放置

我试图在你的脚本和css的源代码中查找速度,但没有找到。 您不需要将所有元素封装在

基于

元素是元数据(关于数据的数据)的容器,位于
标记和
标记之间。 HTML元数据是关于HTML文档的数据。元数据不显示。 元数据通常定义文档标题、字符集、样式、链接、脚本和其他元信息。 以下标记描述元数据:

因此,您必须移除头部的div,修复源代码,并将
放在主体内部


这是我修复的代码:

太棒了!我希望加载的atom在单击链接时覆盖整个页面(将其放在中间)(页面上的所有内容都将消失)。我该怎么办?(请帮助重新编辑代码)。此外,在我尝试加载的页面的
部分,我有一个指向css的链接,该链接仅应用于我尝试加载的页面。这就是为什么我从
启动rendering元素render me。如何加载整个页面,以便我试图抓取的页面的
也被抓取。
<html>
<head>
<meta charset="utf-8" />
<div id="render-me">
<title>jQuery Ajax Test</title>
<script type="text/javascript" src=" https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://www.gossipper.com/content/css/inspired-mob/styles/pace-theme-center-atom.css" />

  <script>
    paceOptions = {
  ajax: true, // disabled
  document: true, // disabled
  eventLag: true, // disabled
  elements: {
    selectors: ['#render-me']
  }
};
  </script>
  <script src="https://www.gossipper.com/content/css/inspired-mob/js/pace.js"></script>

<script type="text/javascript"><!--

$(document).ready(function(e){
    $.ajaxSetup ({
        cache: false
    });
    var page;
    $('a.lnk').click(function(){

        page = $(this).attr('href');

        $('#render-me').load(page + ' #render-me');

        if(page != location.href){
          window.history.pushState({path:page},'',page);
          $(window).bind("popstate", function() {
              link = location.pathname.replace(/^.*[\\/]/, ""); // get filename only
    $('#render-me').load(link + ' #render-me');
});
        }       

        return false;
    });
    document.addEventListener('gg', function(){
      document.querySelector('.pace').classList.remove('pace-inactive');
      document.querySelector('.pace').classList.add('pace-active');

      document.querySelector('.pace-progress').setAttribute('data-progress-text', percentComplete.value + '%');
      document.querySelector('.pace-progress').setAttribute('style', '-webkit-transform: translate3d(' + percentComplete.value + '%, 0px, 0px)');
    });
    $(window).on({
        popstate:function(e){
            page = location.href;
            $('#render-me').load(page + ' #render-me');
        }
    });

});
</script>
</head>
<body>
<h1>Web page test.html</h1>
<a href="https://www.gossipper.com/forum/general/news/22853-dino-melaye-injured-rushed-to-hospital-after-jumping-off-a-police-vehicle" title="Get extern" class="lnk">Get extern</a>

<div id="content">Initial content in test.html</div>

</body>
</div>
</html>