在我的地盘我有组合框在PHP中:如何发送参数POST方法在AJAX
<script type="text/javascript">
function showUserVisits(reservationObjectId)
{
//alert(reservationObjectId);
if (reservationObjectId == "")
{
document.getElementById("txtHint").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("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","get_user.php?q=" +reservationObjectId,true);
xmlhttp.send();
}
</script>
<form>
<select name="users" onchange="showUserVisits(this.value)">
<!-- <option value="">Select a person:</option> -->
<option value="1">aaa1</option>
<option value="2">aaa2</option>
<option value="3">aaa3</option>
<option value="4">aaa4</option>
</select>
</form>
当组合框的用户变化的项目,方法showUserVisits由AJAX调用。我必须将reservationObjectId传递给get_user.php站点。如何完成GET方法,我想通过POST方法传递此参数,因为在GET方法中,有人可以更改ID。我该怎么做 ?
感谢
不要被愚弄,也可以编辑邮件项目,就像获取项目。只要确保你总是检查你的数据。 –
@John你的意思是,如果请求通过'post'方法发送参数将显示在url中? – tnanoba
@DaHaKa:不在URL中,但可以使用浏览器扩展轻松修改POST参数 – xbonez