我在使用 jquery 在 php 中发送获取请求时遇到问题。它只是无法检测到获取值这里是我的代码:
function getopmerking($id) {
document.getElementById("popup_box").style.display = "block";
$httpreq = new XMLHttpRequest();
$httpreq.onreadystatechange = function () {
document.getElementById("txtouders").innerText = $httpreq.responseText;
document.getElementById("requesteddata").innerText = $id;
}
$httpreq.open("GET", "files/request.php?q=1",true);
$httpreq.send();
}
和我的php代码:
$id = $_GET["q"];
fetchData();
function fetchData()
{
$drow = mysql_fetch_array(mysql_query("SELECT * FROM `tblreservering` where fldllnid=$id;"));
if(!empty($drow))
{
$drow['fldopmerking'];
}else{
echo "id is: ".$id."geen gegevens gevonden!";
// i only get "id is: geen gegevens gevonden!" as output since $id is nothing.
}
}