Html 从外部Web服务获取响应,该服务应该只刷新我的joomla网页的一部分
我是乔姆拉的新手。我使用了此处显示为我的web服务的链接:。 然后实现了一个代码,将一些值发布到web服务并获得响应,但它会重新加载我托管的joomla站点的整个页面,并在我尝试将响应值设置为form as answer时显示空表单,因为刷新了网页。然后将值设置为null。它没有在表单中显示答案,因为我使用了条件来检查表单属性是否为null。它应该显示空表单,但我可以在重新加载表单之前使用“echo$response;”来显示响应值。我尝试使用会话,但它不是解决此问题的方法。谁能帮我想出一个办法来修理那个plzHtml 从外部Web服务获取响应,该服务应该只刷新我的joomla网页的一部分,html,xml,web-services,joomla,http-post,Html,Xml,Web Services,Joomla,Http Post,我是乔姆拉的新手。我使用了此处显示为我的web服务的链接:。 然后实现了一个代码,将一些值发布到web服务并获得响应,但它会重新加载我托管的joomla站点的整个页面,并在我尝试将响应值设置为form as answer时显示空表单,因为刷新了网页。然后将值设置为null。它没有在表单中显示答案,因为我使用了条件来检查表单属性是否为null。它应该显示空表单,但我可以在重新加载表单之前使用“echo$response;”来显示响应值。我尝试使用会话,但它不是解决此问题的方法。谁能帮我想出一个办法
<?php
if (isset($_POST['Fahrenheit'])&&$_POST['Fahrenheit']!=null) {
$res = print_name($_POST['Fahrenheit']);
print_form($res);
}
else {
if($res == "")
print_form($res);
}
// In this function we print the name the user provided.
function print_name($name) {
$ch = curl_init();
$far = 'Fahrenheit='.$name;
curl_setopt($ch, CURLOPT_URL,"http://www.w3schools.com/webservices/tempconvert.asmx/FahrenheitToCelsius");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$far);
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
return $server_output;
}
// This function is called when no name was sent to us over HTTP.
function print_form($val) {
echo '
<form method="post">
<table>
<tr>
<td>Fahrenheit to Celsius:</td>
<td><input class="frmInput" type="text" size="30" name="Fahrenheit"></td>
</tr>
<tr>
<td></td>
<td align="right"><input name="cel" type="submit" value="Submit" class="button"></td>
</tr>
<tr>
<td></td>
<td align="right">'.$val.'</td>
</tr>
</table>
</form>
';
}
重新加载时,您的页面将再次调用该服务。在问题中添加代码片段,找出哪里出了问题,哪里出了问题。请在问题中添加一些相关代码。我上传了代码。我没有任何想法。我搜索了这么多链接。但它工作不正常。请给我一个与joomla代码匹配的代码片段解决方案。我用ajax测试了另一个代码,以刷新另一个代码php文件和电子邮件在没有刷新表单的情况下得到响应。但这给了我另一个问题。我可以将该文件上载到服务器。但joomla不支持它。我没有将其上载到joomla后端。因为它应该作为文章上载。它也不支持php