使用Jquery(append)和变量刷新div时出现问题
在使用日期选择器恢复日期之后,我想在JSP中的一个特殊div中发布对象的新闻属性 问题是所有页面都在我的div中重新加载 这是关于Jquery和Ajax的一部分。我想展示“使命”的属性: 然后是关于我的JSP的代码:使用Jquery(append)和变量刷新div时出现问题,jquery,ajax,variables,Jquery,Ajax,Variables,在使用日期选择器恢复日期之后,我想在JSP中的一个特殊div中发布对象的新闻属性 问题是所有页面都在我的div中重新加载 这是关于Jquery和Ajax的一部分。我想展示“使命”的属性: 然后是关于我的JSP的代码: <p>Choisir une date: <input type="text" id="datepicker" /></p> <div id="tab" class="container"> <div class="co
<p>Choisir une date: <input type="text" id="datepicker" /></p>
<div id="tab" class="container">
<div class="content">
<table class="table table-striped" >
<thead>
<tr>
<th class="center-td">Date d'execution</th>
<th class="center-td">client</th>
<th class="center-td">site depart</th>
<th class="center-td">site arrivee</th>
<th class="center-td">Vehicule</th>
<th class="center-td">commentaire</th>
<th class="center-td"></th>
</tr>
</thead>
<tbody>
<c:forEach var="mission" items="${listMission}" >
<tr>
<td><c:out value="${mission.date }"/></td>
<td><c:out value="${mission.nomClient }"/></td>
<td><c:out value="${mission.siteDepart.adresse }"/></td>
<td><c:out value="${mission.siteArrivee.adresse }"/></td>
<td><c:out value="${mission.vehicule.modele }"/></td>
<td><c:out value="${mission.commentaire }"/></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
但我不确定
谢谢您想在选项卡中显示与所选日期对应的所有任务吗?在这种情况下,不需要清空div,只需清空表行即可。对于结果数据中的每个对象,在表中添加一行是的,但首先我必须清理任务选项卡,因为默认情况下我会发布当天的任务。然后当我选择日期时,我只想发布今天的任务,而不是前几天的任务。我现在不知道我是否有足够的清晰信息?是的,你是!(法国评论社)。创建一个包含3个步骤的简单函数。第一步:清空表
$(“#matable”)。查找(“tbody>tr”)。删除()
,然后,第二步,调用ajax方法。最后一步,在ajax回调中,为结果中的每个对象创建一行,并将其插入表体var ligne=$(“”)/*用td的*/then、$(“#matable)、find(“tbody”)、append(ligne);
填充您的表。当然,您必须向表中添加ID。
<p>Choisir une date: <input type="text" id="datepicker" /></p>
<div id="tab" class="container">
<div class="content">
<table class="table table-striped" >
<thead>
<tr>
<th class="center-td">Date d'execution</th>
<th class="center-td">client</th>
<th class="center-td">site depart</th>
<th class="center-td">site arrivee</th>
<th class="center-td">Vehicule</th>
<th class="center-td">commentaire</th>
<th class="center-td"></th>
</tr>
</thead>
<tbody>
<c:forEach var="mission" items="${listMission}" >
<tr>
<td><c:out value="${mission.date }"/></td>
<td><c:out value="${mission.nomClient }"/></td>
<td><c:out value="${mission.siteDepart.adresse }"/></td>
<td><c:out value="${mission.siteArrivee.adresse }"/></td>
<td><c:out value="${mission.vehicule.modele }"/></td>
<td><c:out value="${mission.commentaire }"/></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
$("#tab").append(mission)