2012-10-16 91 views
0

我在不刷新的情况下进行页面更新,并阅读了一些教程,并提出了以下代码。但它似乎没有工作。当你按下按钮时,似乎什么也没有发生。无刷新无法正常工作的网页更新

的index.php代码

<!DOCTYPE html> 
<html> 
    <head> 

     <script type="text/javascript" src="jquery.js"></script> 

     <script> 
       function updateShouts() 
       {     
        $('#refresh').load('update.php'); 
        alert('it works!'); uncomment this to know if your script works 
       } 
     </script> 

    </head> 

    <body> 

     <div id="refresh"> 
      <?php 
      include('update.php'); 
      ?> 
      <button onclick="updateShouts()">Try it</button> 

     </div> 


    </body> 

</html> 

update.php代码

<?php 
print strftime('%c'); 
?> 

回答

2

你必须从你的其他脚本

<script type="text/javascript" src="jquery.js"></script> 

<script> 
     function updateShouts() 
     {     
      $('#refresh').load('update.php'); 
      //alert('it works!'); uncomment this to know if your script works 
     } 
</script> 

单独声明您的jQuery的链接,或者您可以使用更新在线jQuery库

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script> 

    <script> 
     function updateShouts() 
     {     
      $('#refresh').load('update.php'); 
      //alert('it works!'); uncomment this to know if your script works 
     } 
    </script> 
+0

我不完全确定你的意思是IoQ? – jskrwyk

+0

注意您的脚本标题?