sendRequest()从javascript到Struts 2中的操作类

时间:2018-08-08 10:27:12

标签: javascript ajax struts2

我想在选择s时调用一个动作:select

jsp片段:

 <s:select list="stateList" 
   name="customerBean.state" 
   onchange="fetchCity()" 
   onselect="fetchCity()" 
   headerKey="0" 
   headerValue="Select"  
   cssClass="form-control" 
   id="state" 
   class="form-control" 
   placeholder="State here" 
   cssErrorClass="form-control is-invalid">

javascript:

<script type="text/javascript">
        function fetchCity() {

            console = document.getElementById('console');
            var selectBox = document.getElementById('state');
            var selectedIndex = selectBox.selectedIndex;
            var selectedValue = selectBox.options[selectedIndex].value;
             alert("AjaxRetrieveUser.action?stateName=" + selectedValue);
            sendRequest("AjaxRetrieveUser.action",
                    "stateName=" + selectedValue, "POST");
        }

问题在于它没有调用动作。 如果我直接将动作调用到http://localhost:8084/IACMS/iacms/jsp/ltr/AjaxRetrieveUser.action?stateName=Washington之类的网络浏览器,则会调用动作。请帮忙。

0 个答案:

没有答案