2014-04-04 64 views

回答

0

你可以嘗試這樣的事情:

PHP文件: file.php

<?php 
    //your php code for random number... 
?> 

HTML文件:

<!DOCTYPE html> 
<html> 
    <head> 
     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
    </head> 
    <body> 
     <input type="button" id="clkMe" value="Load File" /> 
     <div id="response"></div> 
     <script> 
      $(document).ready(function(){ 
       $("#clkMe").click(function(){ 
        var dataString={}; 
        $.ajax({          
         url:"file.php", 
         type: 'POST', 
         cache:false, 
         data: dataString, 
         beforeSend: function() {}, 
         timeout:10000, 
         error: function() { },  
         success: function(response) { 
          $("#response").html(response); 
          alert(response); 
         } 
        }); 
       }); 
      }); 
     </script> 
    </body> 
</html> 

我希望這是你問。

快樂編碼!