【发布时间】:2013-04-25 06:32:52
【问题描述】:
我正在尝试在 java/jsp 项目中实现 jquery 自动完成功能。
自动完成功能即使将术语带到服务器也能正确执行。服务器也会发送在开发人员工具中可见的必要响应。问题是即使在收到响应后,自动完成功能仍会显示 No search results。
这是我的 ajax jsp 页面 - ajaxOtherLocations.jsp - 我在其中查询结果。
<%
String query = (String)request.getParameter("term");
System.out.println(query);
LocationDAO locationModel = new LocationDAO();
ArrayList<LocationBean> locations = locationModel.getLocationsByType("others");
for( LocationBean location : locations )
{
out.print(location.getLocationName()+"\n");
}
%>
在网络选项卡的开发人员工具中,我可以看到一个请求正在发送到上述页面,响应类似于...
LBNagar
Hitech City
Jubilee Hills
Film Nagar
Lakdikapool
Koti
Dilsukhnagar
如您所见,全部由line-end 字符分隔。
我正在像这样调用autocomplete 函数...
$(".auto-complete").keypress(function(){
$(this).autocomplete({source:"ajax/ajaxOtherLocations.jsp"});
});
我哪里做错了?
注意:-我从本教程中获得了一些想法-http://www.java4s.com/jquery-tutorials/example-get-autocomplete-feature-in-javajsp-with-jquery-api/
【问题讨论】:
标签: jquery jsp autocomplete