我需要发送锚点标签上的文本框值点击checkID.php,并显示从PHP页面发送的HTML页面中的响应。我试过使用javascripts。但该页面被重定向到checkID.php页面。需要在相同的html页面中显示。如何从php页面获取响应?
<a href="#" onclick="javascript:fillContent('checkID.php'); ">
Check Availability
</a>
在窗体动作中,我声称为checkID.php。 以下是JavaScript我用
<script language="javascript">
function fillContent(resource)
{
xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", resource, true);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4) {
el = document.getElementById('availabilityResponse')
el.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
</script>
下面
是我的PHP代码
<?php
require_once('lib/nusoap.php');
$client=new nusoap_client("http://localhost/server.php?wsdl");
$error = $client->getError();
if ($error) {
return $error;
}
$alias=$_POST['id'];
$response = $client->call("checkAvailability", array("id" => $alias));
if($client->fault)
{
return $client->faultstring;
}
else
{
$error = $client->getError();
if ($error) {
return $error;
}
else {
return $response;
}
}
?>
如何让html页面的响应和显示?
更具体,你想要什么? – Dev
你能显示你的完整HTML代码吗? – skos
我需要显示来自php代码的响应。这是我的php代码 – anipaul