我将地图返回到post方法,该方法在alert函数中正确显示。如何将地图的值附加到带有ID课程的选择选项?
<script type="text/javascript" >
$(document).ready(function(){
$("select#dept").change(function(){
alert("inside jquery1");
$.post("getCourses.htm",{depName: $(this).val()}, function(j){
$.each(j, function(key, value) {
alert(key + ': ' + value);
});
});
});
});
</script>
</head>
<body>
<h6>Set Course Fee</h6>
<form:form method="POST" commandName="courseFee">
<table cellspacing="7">
<tr>
<td>Department:</td>
<td><form:select path="pk.dept" id="dept">
<form:option value="select" label="select"/>
<form:options items="${deptList}"/>
</form:select></td>
</tr>
<tr>
<td>Course:</td>
<td><form:select path="pk.course" id="course">
</form:select></td>
</tr>
<tr>
<td><input type="submit" value="Save" ></td>
</tr>
</table>
</form:form>
答案 0 :(得分:1)
我会试试这个:
$.post("getCourses.htm",{depName: $(this).val()}, function(j){
var opts = '';
$.each(j, function(key, value) {
opts += '<option value="'+value+'">'+key+'</option>';
});
$('#course').html(opts);
});