Using AJAX with JSP
Hi
I m using AJAX with jsp. In my code call the ajax function on the onChangeEvent of combo as
<select id='combo1' name="ProcessCombo" onchange="ajaxFunction(this);">
I am setting ajaxRequest.responseText to the div tag named as subtab2
function ajaxFunction(process){
var ajaxRequest; // The variable that makes Ajax possible!
try{// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{ alert("Internet");
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{ alert("Internet Catch block");
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
var combo = document.getElementById('combo1').value;
var queryString = "?comboVal=" + combo;
alert(queryString+ " readyState "+ajaxRequest.readyState);
// Create a function that will receive data sent from the server
ajaxRequest.open("GET", "processInfo1.jsp" + queryString, true);
ajaxRequest.send(null);
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
//document.Process.time.value = ajaxRequest.responseText;
//document.Process.processVal.value = ajaxRequest.responseText;
var ajaxDisplay = document.getElementById('subtab2');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
}
The div tag is as
<div id="subtab2">
<Table align="center" border="0" cellpadding="1" cellspacing="1">
<TR>
<%
System.out.println("@@@@@!!!! "+process);
try{
// String abc="LATimes";
enumJ1 = comm.getTransInfo(process);
System.out.println("Size....."+enumJ1.size());
System.out.println("aa1........");
}catch(Exception ex){
out.println("#@@#Exception caused " + ex);
}
%>
<td width="10%">Software Group牋牋</td ><%
try{
System.out.println("aa2........");
for (int k=0;k < enumJ1.size () ;k+=3 )
{
System.out.println("aa3 In loop........");
grpcode = (String)enumJ1.elementAt(k);
out.println(" grpcode: "+grpcode);
grpDescr = (String)enumJ1.elementAt(k+1);
//out.println(" grpDescr: "+grpDescr);
//System.out.println("111rate: "+rate);
//comm.addRate(rate);
System.out.println("aa4........"+grpDescr);
// sGroup=grpcode;
%><input type="button" value="<%=grpDescr%>" name="<%=grpcode%>" >
</tr>
</table>
</div>
<% System.out.println("aa5........");
}
}catch(Exception e){
System.out.println("Exception is..."+e);
}
//sGroup=grpcode;
%>
In this it doesn抰 show button but there are no any errors .All the code goes welll it shows the ideal processing in log file.Can抰 understand wht is the problem..?
Thanks in advance,
Meghna

