【发布时间】:2013-01-19 01:17:58
【问题描述】:
这是我的 javascript:
<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 之后包含它,否则会抛出错误
-
这是我的 jQuery 代码。当您说在 jQuery 之后包含它时,您的意思是在
-
我很感激这个提示,但不幸的是我仍然遇到同样的错误。
-
难道我的 application.js 文件根本就没有 getXMLHTTP 吗?
标签: ajax xmlhttprequest