-1
嗨,我真的很新開發web開發。我想知道如何在php中訪問ajax返回的值。 當我從我的下拉列表中選擇一個選項時,我使用ajax獲得另一個下拉列表。但我想使用php的頁面上的值。如何在php中訪問ajax返回的值
Practice Name :
<select name="practiceName" id="practiceName" onchange="showAssociate(this.value)">
<option value="">Select an option</option>
<option value="abc">abc</option>
<option value="xyz">xyz</option>
</select>
<p>
<div id="associate">
</div>
Ajax代碼是:
function showAssociate(str)
{
if (str=="")
{
document.getElementById("associate").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("associate").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getAssociate.php?q="+str,true);
xmlhttp.send();
}
阿賈克斯將返回在div「聯想」所需的下拉框和價值觀,但我怎麼能在PHP中使用這些值,而在提交表格?我只需要訪問並在屏幕上的某處回顯。請幫忙。 在此先感謝。
縮短並格式化您的代碼。找到一種方式來提出你的問題或更少。 –