2016-04-14 76 views

回答

2

您可以通過jQuery使用load()做到這一點:

$("div").load("http://servername/submit/rest/getHtmlAdvertisements/"); 

PHP使用file_get_contents()

<?php 
$someData = file_get_contents('http://servername/submit/rest/getHtmlAdvertisements/'); 
echo "<div>".$someData."</div>"; 
0

幾種方法,你可以使用PHP curl使網站內容,如:

<?php 
    function curl_post($url){ 
     $ch = curl_init(); 
     curl_setopt($ch, CURLOPT_URL, $url); 
     curl_setopt($ch, CURLOPT_POST, true); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
     $curl_response = curl_exec($ch); 
     curl_close($ch); 
     return $curl_response; 
    } 

    $content = curl_post('http://servername/submit/rest/getHtmlAdvertisements/'); 
?> 

現在你必須修改<div></div>代碼下面顯示的內容:

<div><?php echo $content; ?></div> 

或者使用file_get_contents,如:

<?php 
    $content = file_get_contents('http://servername/submit/rest/getHtmlAdvertisements/'); 
    echo $content; 
?>