我遵循了自动完成示例,但事情没有解决。
JSP 搜索页面:
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script src="${pageContext.request.contextPath}/js/jquery-1.9.0.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery-ui-1.10.0.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.bgiframe.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.ajaxQueue.js"></script>
<script src="${pageContext.request.contextPath}/js/thickbox-compressed.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.autocomplete.js"></script>
<link href="${pageContext.request.contextPath}/css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Hello World!</h1>
<s:textfield id="listCats" name="displayedCatId" key="label_choose_topic" size="80" cssClass="selectedCat" />
</body>
</html>
<script type="text/javascript" >
$().ready(function() {
$("#listCats").autocomplete('/listCategory.action', {
minChars: 1,
max: 15,
multiple: false,
autoFill: true
});
});
</script>
在 struts.xml 中
<action name="listCategory" class="qaplus.action.question.LoadCategoryAction" method="loadCategory">
<result name="success">/WEB-INF/jsp/list_category.jsp</result>
</action>
问题是 jQuery 函数不调用listCateory操作。
我错过了什么吗?
编辑:java脚本控制台报告:
Uncaught TypeError: Cannot read property 'opera' of undefined jquery.autocomplete.js:83
$.Autocompleter jquery.autocomplete.js:83
(anonymous function) jquery.autocomplete.js:32
jQuery.extend.each jquery-1.9.0.js:631
jQuery.fn.jQuery.each jquery-1.9.0.js:253
$.fn.extend.autocomplete jquery.autocomplete.js:31
(anonymous function) sample.jsp:34
fire jquery-1.9.0.js:1017
self.fireWith jquery-1.9.0.js:1127
jQuery.extend.ready jquery-1.9.0.js:416
DOMContentLoaded