I’m trying to get values from the table based on the eqid using the sendxmlRequest() method:
<select name="eqNAME" onchange="sendxmlRequest('GET','getEquipDetails.jsp',this.value)
<options> ..... <options>
</select>
This I have added in ajax.js file
//Make the XMLHttpRequest Object
var http = createRequestObject();
function sendxmlRequest(method, url,eqid){
url = url + "?eqid="+eqid;
if(method == 'get' || method == 'GET'){
http.open(method,url,true);
http.onreadystatechange = handleResponse;
http.send(null);
}
}
function createRequestObject(){
var req; try {
// Firefox, Opera, Safari
req = new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
//For IE 6
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
//For IE 5
req = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
}
}
}
return req;
}
The following is used to handle the response (in ajax.js):
function handleResponse(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
}
}
Here is my ‘getEquipDetails.jsp’ file:
<%
String planLoc= theResult1.getString(2) == null ? "":theResult1.getString(3);
String changLoc= theResult1.getString(3) == null ? "":theResult1.getString(4)
%>
<%
response.setHeader("Pragma", "no-cache"); //HTTP 1.0
response.setDateHeader("Expires", 0); //prevents caching at the proxy server
response.setHeader("Cache-Control", "no-cache, private, no-store, max-stale=0"); // HTTP 1.1
%>
My query is, how do we get the values planLoc and changLoc from the getEquipDetails.jsp and set it in responseText, so that it can be updated in the drop-down in my page?
Or is there any other way to go about it?
Note: I haven’t given the table retrieval code, since that is already taken care of. I just want the planLoc and changLoc updated in my JSP page
In
getEquipDetails.jspWrite values
response.getWriter()object.Then In
For Example:
So, Response from AJAX will be set here.