I'm working with the autocomplete ui by categories, the data is sent normally and the query runs smoothly but in the search engine does not return the data of the json ... what I'm doing wrong and how can I fix it?
<%@ include file="../conectadb.jsp" %>
<%@ page language="java"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Basic Search</title>
<style type="text/css">
.ui-autocomplete-category {
font-weight: bold;
padding: .2em .4em;
margin: .8em 0 .2em;
line-height: 1.5;
}
</style>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
</head>
<body>
<script>
$.widget("custom.catcomplete", $.ui.autocomplete, {
_renderMenu : function(ul, items) {
var that = this, currentCategory = "";
$.each(items, function(index, item) {
if (item.category != currentCategory) {
ul.append("<li class='ui-autocomplete-category'>" + item.category + "</li>");
currentCategory = item.category;
}
that._renderItemData(ul, item);
});
}
});
</script>
<script type="text/javascript">
$(function() {
$( "#search" ).catcomplete({
delay: 0,
minLength: 3,
source: function(request, response) {
$.ajax({
url : "getsearchjson.jsp",
dataType : "json",
data :"searchText=eric",
success : function(data) {
console.log(data);
} //success
});
}
});
});
</script>
<p />
<div class="container well">
<div class="row-fluid">
<form action="search" method="get">
<div class="input-append">
<input type="text" name="query" id="search" placeholder="Search.."/>
</div>
</form>
</div>
</div>
</body>
</html>
<%@ include file="../conectadb.jsp" %>
<%
response.setContentType("application/json");
String term=request.getParameter("searchText");
%>
[
<%
COMANDO = "SELECT ID, "+
"ORDEN, "+
"NOMBRE GRUPO, "+
"CODIGO, "+
"NOM_SERV(ID_SERVICIO) SERVICIO, "+
"ID_SERVICIO "+
"FROM CATALOGO_NIVEL"+
"WHERE (NOMBRE LIKE UPPER ('%"+term+"%') OR ID_SERVICIO = '"+term+"') ";
rset = stmt.executeQuery(COMANDO);
while(rset.next() ){
%>
{ label: "<%=rset.getString("SERVICIO")%>", category: "<%=rset.getString("GRUPO")%>"},
<%}%>
{label:"", category:""}
];