I am trying to connect to my action class by using URL as below in Ajax. But its not going into my action class and even it is not showing the selected value by using $("#selectedCountry").val()
.
function getstates(){
alert($("#selectedCountry").val());
$.ajax({
type : "GET",
url : "/ThirdTask/selectstate.action",
dataType : 'text',
data : "name="+$("#selectedCountry").val(),
success : function(){
$('statesdivid').html();
},
error : alert("No values found..!!")
});
}
My JSP code as follows:
<s:select name="selectedCountry" list="{'india','china'}" onclick="getstates();"/></div>
<div id="statesdivid">
<s:if test="%{#request.selectedstatenames != null}">
<s:select list="#request.selectedstatenames" name="selectedState">
</s:select>
</s:if>
</div>
My struts.xml
:
<action name="selectstate.action" class="com.thirdtask.actions.SelectAction" method="selectstate">
<result name="success">selecttag.jsp</result>
</action>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…