Hi all ! I want to know if this is possible and if you have an example you could show. So far Im trying like this:
function ajaxFunction(){
alert("ajaxFunction");
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
appendOptionLast(ajaxRequest.responseText);
}
}
//var age = document.getElementById('age').value;
//var wpm = document.getElementById('wpm').value;
//var sex = document.getElementById('sex').value;
//var queryString = "?age=" + age + "&wpm=" + wpm + "&sex=" + sex;
//alert("Antes open");
ajaxRequest.open("GET", "/TWC/Comun/Ajax.jsp", true);
//alert("Despues open");
ajaxRequest.send(null);
}
And here is my JSP thats doing the query.
<%@page contentType="text/html"%>
<%@ page import="beans.*,java.util.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix=sql %>
<%@page pageEncoding="ISO-8859-1"%>
<sql:setDataSource dataSource=jdbc/TWC />
<sql:query var=qryItems >
SELECT User_ID
FROM product
ORDER BY nombre
</sql:query>
<c:forEach var=row items=${qryItems.rows}>
User: <c:out value=${row.User_ID} /><br>
</c:forEach>
Thanks!