这段jquery代码假设在下拉选择中执行表单提交。它适用于我们的测试网站。 但是一旦我们将它发布到我们的实时网站,它就会中断。有人能看出它有什么问题吗?
(ASP /执行代码如下) PAGE:http://www.casa.gov.au/scripts/nc.dll?WCMS:PWA::pc=PC_91330
ASP代码:
<script>
$(document).ready(function() {
$(document).on("change","select#state",function(e){
$("form").submit();
});
});
</script>
<form action="avsafety.asp" method="get">
<p>State:<br/>
<select id="state" name="state">
<option label="ACT" value="ACT" <%if request.querystring("state") = "ACT" then response.write("selected") %>>ACT</option>
<option label="NSW" value="NSW" <%if request.querystring("state") = "NSW" then response.write("selected") %>>NSW</option>
<option label="NT" value="NT" <%if request.querystring("state") = "NT" then response.write("selected") %>>NT</option>
<option label="QLD" value="QLD" <%if request.querystring("state") = "QLD" then response.write("selected") %>>QLD</option>
<option label="VIC" value="VIC" <%if request.querystring("state") = "VIC" then response.write("selected") %>>VIC</option>
<option label="SA" value="SA" <%if request.querystring("state") = "SA" then response.write("selected") %>>SA</option>
<option label="TAS" value="TAS" <%if request.querystring("state") = "TAS" then response.write("selected") %>>TAS</option>
<option label="WA" value="WA" <%if request.querystring("state") = "WA" then response.write("selected") %>>WA</option>
</select>
<input type="submit" value="Search" />
</p>
</form>
现场网站上的代码:
<script type="text/javascript">
$(document).ready(function() {
$(document).on("change","select#state",function(e){
$("form").submit();
});
});
</script>
<form action="avsafety.asp" method="get">
<p>
State:<br />
<select id="state" name="state">
<option label="ACT" value="ACT">
ACT
</option>
<option label="NSW" value="NSW">
NSW
</option>
<option label="NT" value="NT">
NT
</option>
<option label="QLD" value="QLD">
QLD
</option>
<option label="VIC" value="VIC">
VIC
</option>
<option label="SA" value="SA">
SA
</option>
<option label="TAS" value="TAS">
TAS
</option>
<option label="WA" value="WA">
WA
</option>
</select> <input type="submit" value="Search" />
</p><input type="hidden" name="session" value="1918276309" />
</form>
答案 0 :(得分:4)
您使用的是古老版本的jQuery,1.2.6
没有.on()
,您需要升级到版本1.7+才能使用它。此外,您可能希望在您提交的表单中更具体(例如给它一个id),因为页面上有多个。