0
这里是我的javascript:得到一个getXMLHTTP没有定义错误
<script type="text/javascript">
function getState(countryId)
{
var strURL="findState.php?country="+countryId;
var req = getXMLHTTP();
//ERROR is right here
//UNCAUGHT REFERENCE ERROR: getXMLHTTP IS NOT DEFINED
if (req)
{
req.onreadystatechange = function()
{
if (req.readyState == 4)
{
// only if "OK"
if (req.status == 200)
{
document.getElementById('statediv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
</script>
它正在从这个所谓:
<tr>
<td width="150">Country</td>
<td width="150"><select style="background-color: #ffffa0" name="country" onchange="getState(this.value)"><option>Select Country</option><option value="1">USA</option><option value="2">Canada</option> </select></td>
</tr>
为安全起见,这是我的头,也许我做的这不正确?
<head>
<link rel="stylesheet" type="text/css" href="view/css/application.css" />
<script type="text/javascript" src="view/javascript/application.js" ></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
</head>
另外要注意的,我工作过this例子,他是使用MySQL服务器,我使用ODBC连接到Access数据库。我不会为此使用xmlHTTP吗?我真的不知道。
是什么的application.js?如果它是你的jQuery代码包括它后jQuery否则会引发错误 – dmi3y
这是我的jQuery代码。当你说包括它后面的jQuery你的意思是