Привет. Я пытался добавить записи из формы, которые регистрируют или обновляют студента, но это не работает.В чем может быть причина?вот что я попробовал:
<table id="allStudent" class="table table-bordered">
<thead>
<tr>
<th>FirstName</th>
<th>LastName</th>
<th>studentCode</th>
<th>Major</th>
<th>FatherName</th>
<th>Action</th>
</tr>
</thead>
<script id="script" type="text/template">
<tbody id="body">
<%--<c:forEach items="${list}" var="student">--%>
<tr >
<td>
${firstName}
<%--<c:out value="${student.firstName}"/>--%>
</td>
<td>
${lastName}
</td>
<td>
${studentCode}
</td>
<td>
${major}
</td>
<td>
${fatherName}
</td>
<td>
<a href="" class="btn btn-success" role="button"><i class="fa fa-pencil"
style="padding-right: 10px;"></i>
Update </a>
<button onclick="" class="btn btn-danger" role="button"><i class="fa fa-trash"
style="padding-right: 10px;"></i>Delete
</button>
<a href="" class="btn btn-info" role="button"><i class="fa fa-check"
style="padding-right: 10px;"></i>Course
Selection
</a>
</td>
</tr>
</tbody>
</script>
и я использую шаблон jQuery с ajax для добавления данных, которые при каждой регистрации я вижу в таблице:
var d = {data: JSON.stringify(dataToPost)};
console.log(dataToPost);
$.ajax({
type: "POST",
dataType: "json",
ContentType: "application/json",
url: "student?method=saveOrUpdate",
data: d,
success: function (data) {
all();
},
error: function (data) {
alert("error occured");
}
});
});
});
function all()
{
$.ajax({
type: "POST",
dataType: "json",
ContentType: "application/json",
url: "student?method=findAll",
success: function (data) {
$("#script").tmpl(data).appendTo("#body");
var ht = data.msg;
$("#resp").html(ht);
},
error: function (data) {
alert("error occured");
}
});