Hi All,
I am new to ajax I am trying to call an action class from AJAX but i my code is not working please check my code and do the needful
i created a drop down which have value ,when i change the value then it should go to the action class and execute the logic.
<script type="text/javascript">
function selectDropdown(){
var xmlhttp;
xmlhttp=new XMLHttpRequest();
alert("xmlhttp :"+xmlhttp);
var a=document.getElementById("dropdown").value;
var url="adddropdown.do?a="+a;
xmlhttp.open("GET",url,true);
xmlhttp.onreadystatechange=function(){
if(this.readystate==4){
document.getElementById("dropdown1").innerHTML=xmlHttp.responseText;
}
}
}
</script>
<body>
<form name="form1" action="/adddropdown">
<table>
<tr>
<td>
<h1>Select</h1>
</td>
<td><select id="dropdown" name="dropdown"
onchange="selectDropdown()">
<option value="India">India</option>
<option value="US">US</option>
<option value="UK">UK</option>
<option value="Japan">Japan</option>
<option value="China">China</option>
</select></td>
</tr>
<tr>
<td>
<h1>Select submenu</h1>
</td>
<td><select id="dropdown1" name="dropdown1">
</select></td>
</tr>
</table>
</form>
</body>
struts-config.xml file
<action path="/adddropdown" type="com.Action.Questions">
action class
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("sample");
String drvalue=request.getParameter("a");
System.out.println("drvalue :"+drvalue);
return mapping.findForward("questions");
}
In action class i am printing some sample value and request object but none of the values are printed. please help me in resolving my problem
Thanks in advance,
venkat.