Estoy trabajando con el 'ui autocomplete' por categorías, los datos se envían con normalidad y la 'query' se ejecuta sin problemas, pero en el buscador no me retorna la 'data' del 'json'... ¿qué es lo que estoy haciendo mal y cómo puedo solucionarlo?
<%@ 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:""}
];
console.log(data)
dentro delsuccess
te pinta los resultados esperados?