2012-10-16 2 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

스크립트 헤더를 확인 하시겠습니까?