2016-04-14 36 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; 
?>