如何使用ajax在jsp页面中使一个组合框依赖于其他组合框?

时间:2016-07-07 06:19:47

标签: java jquery ajax jsp

当我从组合框调用jquery代码时,我应该从哪里获取其他组合框的详细信息?

例如:如果我选择CSE分支,那么xhr请求应该转到JAVA页面或JSP页面

如果请求转到JAVA servlet,那么执行此操作的确切方法是什么?

    enter code here<!DOCTYPE html>
<html lang="en">
<head>
<%@page import="model.to.BranchInfo"%>
<%@include file="meta.jsp" %>
       <title>Blog Single | Corlate</title>

    <%@include file="css.jsp" %>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <link rel="apple-touch-icon-precomposed" href="images/ico/apple-touch-icon-57-precomposed.png">
<script type="text/javascript" src="jquery-1.11.2.js"></script>
    <script type="text/javascript">
      $("document").ready(function(){
         $("#value").change(function(){
             var val = $(this).val();
             var address ="ajaxsubject.jsp?value=" + val;
             $.ajax({url:address,success:function(result){
             $("#div").html(result);
             }});
         }) ;
      });
        </script>

</head><!--/head-->
<body>
    <%@ include file="header.jsp" %>
    <br>
    <form method="get">
<label for="bname">Choose Branch Name</label> 
<select name="branch_id" class="form-control" id="value">
                        <option selected="selected">Select a branch</option>
                        <c:if test="${allbranch!=null}">
                        <c:forEach var="item" items="${allbranch}">
                            <option value="${item.branch_id}">${item.branch_id}</option>
                                </c:forEach>
                            </c:if>
                        </select>

    <br><br>
    <section>
    <div id="div" >


    </div>



    </section>
    </form>

</body>
</html>

0 个答案:

没有答案