我正在使用spring mvc,我正在使用ajax jQuery,但我可以在其中添加元素。但是当我将更改事件发送到Dropdownbox时,我无法调用jQuery。我可以在这里找到任何建议吗?
JSP代码: -
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1 align="center">Model Registration</h1>
<br>
<div align="center">
<form:form method="post" action="add" commandName="employee">
<table>
<tr>
<td><form:label path="name">
<spring:message code="label.firstname" />
</form:label></td>
<td><form:input path="name" /></td>
</tr>
<tr>
<td><form:label path="surname">
<spring:message code="label.lastname" />
</form:label></td>
<td><form:input path="surname" /></td>
</tr>
<tr>
<td><form:label path="email">
<spring:message code="label.email" />
</form:label></td>
<td><form:input path="email" /></td>
</tr>
<tr>
<td><form:label path="company">
<spring:message code="label.telephone" />
</form:label></td>
<td><form:input path="company" /></td>
</tr>
<tr>
<td><form:label path="salary">
<spring:message code="label.salary" />
</form:label></td>
<td><form:input path="salary" /></td>
</tr>
<tr>
<td><form:label path="country">
<spring:message code="label.country" />
</form:label></td>
<td><form:select id="cbox" path="country"
items="${countrylist}" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit"
value="<spring:message code="label.add"/>" /></td>
</tr>
</table>
</form:form>
</div>
</body>
</html>
和jQuery函数:
$(document).ready(function() {
$('#cbox').on('change',function() {
alert("change done!!!");
});
$('#cbox').trigger('change');
});
html源页面: -
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="/SpringEmployeeSpringHibernateJquery/resources/js/jquery.min.js"></script>
<script src="/SpringEmployeeSpringHibernateJquery/resources/js/jquerycall.js"></script>
</head>
<body>
<h1 align="center">Employee Edit list</h1>
<button id="clickchech" value="Clicked" onclick="first()">Click Here</button><br><br>
<!-- <button id="clickstate" value="Clicked">Click Here</button><br><br> -->
<div id="result">Main From Data</div>
</body>
</html>
答案 0 :(得分:1)
有一件事你可以检查一下,包括所有的java脚本库进入你使用所有库的所有页面。 ??
这意味着如果我包含其他页面,那么你仍然需要将这些库包含在其他页面中。