jQuery ajax 加载页面

 test.php

  
  
  
  
  1. <?php 
  2.     $filename = "http://www.zj.com/news_hongniang.html"
  3.     $content = file_get_contents($filename);//把整个文件读入一个字符串中 
  4.     preg_match("/<body>(.*)<\/body>/isU" ,$content$arr);//取<body>之间的内容 
  5.      $content = str_replace(array("<body>""</body>"), ""$arr[0]);//去掉<body> 
  6.     echo $content
  7. ?>  

 

 test.html

  
  
  
  
  1. <script src="jquery-1.4.2.min.js"></script> 
  2.  
  3. <div id="sj"></div> 
  4.  
  5. <script type="text/javascript"
  6.     $(function(){ 
  7.         $.get("test.php"function(data){ 
  8.             $("#sj").html(data); 
  9.         }); 
  10.     }) 
  11. </script>  

 

你可能感兴趣的:(jquery,Ajax)