我想做的是
我有以下代码:
JQUERY
$("#currentItem").focus(loadPlantilla);
function loadPlantilla() {
var code = $("#code").val();
$.ajax({
url: './profile/ViewPlantillaPicker?code=' + code,
type: 'POST',
}).done(function() {
$('#modal').modal('show');
});
}
SERVLET
int code = Integer.parseInt(request.getParameter("code"));
...
List<PlantillaView> plantilla = dao.read(...);
HttpSession session = request.getSession();
session.setAttribute("plantilla", plantilla);
MARKUP
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
...
<div class="modal-body">
<table class="table table-striped table-bordered table-hover">
<thead> ... </thead>
<tbody>
<c:forEach var="plantilla" items="${sessionScope.plantilla}">
<tr>
<td><c:out value="${plantilla.getItemCode()}"/></td>
<td><c:out value="${plantilla.getNewItemCode()}"/></td>
<td><c:out value="${plantilla.getPosition()}"/></td>
<td><c:out value="${plantilla.getStation()}"/></td>
<td class="tools">
<form action="PickPlantilla" method="post" class="tool-options">
<input type="hidden" name="itemCode" value="${plantilla.getItemCode()}">
<button type="submit" class="btn btn-default" data-toggle="tooltip" data-placement="right" title="Select">
<span class="glyphicon glyphicon-hand-up"></span>
</button>
</form>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
</div>
问题
发出请求后,会显示模态,但即使设置了新值,它仍然包含会话的先前值。我该如何解决?我在使用location.reload();
显示模态之前尝试刷新页面,但显然它不是正确的解决方案。请帮帮忙?
如果有更好的方法(最有可能),请告诉我。此外,我是JQuery和AJAX的新手,因此非常感谢您对解决方案的一些解释。