Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Ajax + jsp

Estas en el tema de Ajax + jsp en el foro de Frameworks JS en Foros del Web. Buenas !! Soy nuevo tanto en el foro como en ajax, tengo el siguiente codigo que me funciona correctamente pero lo quiero ampliar, que cuando ...
  #1 (permalink)  
Antiguo 07/04/2011, 04:00
 
Fecha de Ingreso: abril-2011
Mensajes: 1
Antigüedad: 13 años
Puntos: 0
Ajax + jsp

Buenas !!

Soy nuevo tanto en el foro como en ajax, tengo el siguiente codigo que me funciona correctamente pero lo quiero ampliar, que cuando en el input text le ponga una letra esta me la pase al javascript i de el javascript al jsp para hacer la query.

JavaScript

Cita:
function objetoAjax(){
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}

function MostrarConsulta(){
divResultado = document.getElementById('resultado');
ajax=objetoAjax();
ajax.open("GET", "search.jsp");
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divResultado.innerHTML = ajax.responseText
}
}
ajax.send(null);
}
Form HTML donde llamo al JS

Cita:
<form name="search" action="" onkeyup="return MostrarConsulta();">
<input type="text" name="valor"/>
</form>
JSP QUERY
Cita:
<%
String sql="select nom, cognoms from tabla";
ps = conexion.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()){
out.println(""+rs.getString(1)+" "+rs.getString(2)+"");
}
rs.close();
ps.close();
%>
P.D: Mientras me expliqueis como hacer llegar la variable (letra, cadena) al javascript i del javascript al jsp, ya montare yo la query con el LIKE

Muchas Gracias !!

Etiquetas: ajax, jsp
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:06.