我将这个web服务调用到我的curl文件中,并且响应是用XML表示的。现在,当我在浏览中预览时,它不显示Google地图,而是显示html标记。
$data= "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ser='http://services.webservices.vub.com/'>
<soapenv:Header/>
<soapenv:Body>
<ser:googlemap>
<!--Optional:-->
<address>ijzerenmolenstraat, leuven Belgium</address>
</ser:googlemap>
</soapenv:Body>
</soapenv:Envelope>";
$url="http://localhost:8080/Venue_Finder_Soap_Version_/VenueFinder?WSDL";
$response=curl_soappost_call($url,$data);
echo "<pre>";
print_r($response);
echo " </pre>";
输出:所有html标记
发布于 2013-07-29 13:26:19
我将使用jquery将内容添加到DOM中。这样,新的HTML、JS和CSS将得到正确的呈现/执行。尝试以下几点:
页面正文部分中的:
在页面上放置一个具有唯一id属性的空div,您希望在其中显示内容,例如:
<div="the_google_map"></div>
在页面的头部分:
// include the jquery library (Can be downloaded and hosted on your own server if desired)
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
$(document).ready(function(){ // don't run this code until the DOM is ready
// get the content
$data= "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ser='http://services.webservices.vub.com/'>
<soapenv:Header/>
<soapenv:Body>
<ser:googlemap>
<!--Optional:-->
<address>ijzerenmolenstraat, leuven Belgium</address>
</ser:googlemap>
</soapenv:Body>
</soapenv:Envelope>";
$url="http://localhost:8080/Venue_Finder_Soap_Version_/VenueFinder?WSDL";
$response=curl_soappost_call($url,$data);
// use jquery to insert the content into the DOM
// Note the div id value here matches the div id used in the body
$('#the_google_map').append($response);
});
https://stackoverflow.com/questions/17913006
复制相似问题