以下代码仅在函数setDiv,行
时有效 //alert("waarom fout");
没有评论,这怎么可能?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link href="stijl.css" rel="stylesheet" type="text/css" />
<title>garage DDT</title>
<script>
function getHTTPObject()
{
if (window.ActiveXObject)
return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest)
return new XMLHttpRequest();
else{
alert("Your web browser does not support AJAX.");
return null;
}
}
function setDiv(s){
//alert("waarom fout");
if(httpObject.readyState==4){
document.getElementById(s).innerHTML=httpObject.responseText;
}
}
function vulDiv(s){
query="occasiewagens2.php?action="+s;
if(s=="tabel" || s=="model")
query+="&merk="+document.getElementById("merkSelect").options[document.getElementById("merkSelect").selectedIndex].value;
if(s=="tabel")
query+="&model="+document.getElementById("modelSelect").options[document.getElementById("modelSelect").selectedIndex].value;
httpObject=getHTTPObject();
if(httpObject != null){
httpObject.open("GET",query, true);
httpObject.send(null);
httpObject.onreadystatechange=setDiv(s);
}
}
var httpObject=null;
</script>
</head>
<body>
<div >
<?php include("header.php") ?>
<input type="button" value="Zoek occasie" onclick="vulDiv('merk')"/>
<p id="merk"> </p>
<p id="model"> </p>
<div id="tabel">
</div>
</div>
</body>
</html>
答案 0 :(得分:3)
您没有分配该功能,而是立即执行该功能
httpObject.onreadystatechange=setDiv(s);
//vs
httpObject.onreadystatechange = function () {
setDiv(s);
};