2014-08-28 54 views
2

我想使用AJAX(默认情况下)从jquery移动页面中的链接(称为第一页)加载页面(称为第二页)。第二页包含一个进度条(jquery-ui)。当我点击第一页的链接时,旋转轮连续旋转,第二页永不加载。我应该知道的东西?我已经看了很多不同的职位,但没有发现任何回答我的问题...AJAX加载和progressbar不兼容?

这里的第一个页面代码:

<html> 
    <head> 
     <meta charset="utf-8"> 
     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.css" /> 
     <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> 
     <script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"></script> 
    </head> 
    <body> 
     <div data-role="page" id="first_page" data-title="MediaManager"> 
      <a href="second_page.php">Espace disque</a> 
     </div> 
    </body> 
</html> 

这里的第二页代码:

<html> 
    <head> 
     <meta charset="utf-8"> 
     <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> 
     <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> 
     <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script> 
    </head> 
    <body> 
     <div id="progressbar"></div> 
     <script> 
       $("#progressbar").progressbar({max: 10 }); 
       $("#progressbar").progressbar({value: 3 }); 
     </script> 
    </body> 
</html> 

谢谢你你的帮助!

+0

你缺少一些代码。您只显示进度栏的一些代码,但我们还需要查看ajax代码。另外你在努力解决这个问题时尝试了什么? – 2014-08-28 18:11:23

+0

如果我直接在浏览器中访问第二页的URL,此代码工作得非常好。 Jquery-mobile正在为我处理AJAX代码,我只在第一页使用了标记。我可以通过_data-ajax =“false”_禁用AJAX,并且页面加载正确,但我需要使用AJAX加载,所以它不是一个选项。 – morpheus65535 2014-08-28 18:17:09

+1

因此,你第一页然后。很明显,这是有问题的网页,而不是你发布的网页。 – Tasos 2014-08-28 18:21:29

回答

0

Omar帮我解决了我的问题。

JQM在使用AJAX进行调用时不使用,所以我必须包含jquery-ui。我已经从第一页中删除了已经在DOM中加载的jquery-core。最后,我必须在pagecontainer事件中分配我的jquery脚本。

下面是我的第二页的工作代码:

<html> 
    <head> 
     <meta charset="utf-8"> 

    </head> 
    <body> 
     <div data-role="page" id="disk-space" data-title="Espace disque"> 
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> 
      <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script> 

      <div id="progressbar"></div> 
      <script> 
       $(document).on("pagecontainershow", function() { 
        $("#progressbar").progressbar({max: 10 }); 
        $("#progressbar").progressbar({value: 3 }); 
       }); 
      </script> 
     </div> 
    </body> 
</html> 

谢谢奥马尔! :-)