1
我试图基于使用sendxmlRequest()方法eqid从表中获取值的responseText值:要获得一个AJAX调用
<select name="eqNAME" onchange="sendxmlRequest('GET','getEquipDetails.jsp',this.value)
<options> ..... <options>
</select>
这我ajax.js文件添加
//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;
}
用于处理响应(在ajax.js)以下:
function handleResponse(){
if(http.readyState == 4 && http.status == 200){
var response = http.responseText;
}
}
这里是我的“getEquipDetails.jsp”文件:
<%
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
%>
我的查询是,我们如何从getEquipDetails.jsp获取值planLoc和changLoc并将其设置在responseText的,所以它可以更新在我的网页下拉?
或者还有什么其他方式可以解决吗?
注:我没有给出表检索代码,因为这已经被照顾。我只是想planLoc和changLoc在我的JSP页面