我的表格中有9列choosen_emails_1
,choosen_emails_2
,choosen_emails_3
,booking_address
,booking_number
,booking_message
,booking_date
,request_date
和user_email
for
循环迭代并打印除user_email
和booking_number
之外的所有内容
我在控制器类中使用Println
语句来检查查询选择器是否正在选择表中的所有列并打印所有 9 列
所以后端代码没有问题。 谁能告诉我这个jQuery是否有任何问题! 代码
data = "";
myfunction = function() {
$('.tablecontainer').show();
load();
}
load = function() {
$.ajax({
url: 'updatedservicerequests',
type: 'POST',
data: {}, // function to get the value from jsp page and send it to mapped class function//
success: function(response) { // if the backend process is success then the function will run by getting the response as its parameter//
alert(response.message);
data = response.data;
alert(response.data);
$('.tr').remove();
alert(response.data);
$(function() {
for (i = 0; i < response.data.length; i++) {
$("#table").append(response.data[i].user_email + "'>" + response.data[i].booking_number + " </td> <td> " + response.data[i].booking_address + " </td> <td> " + response.data[i].booking_date + " </td> <td> " + response.data[i].booking_message + " </td> <td> " + response.data[i].request_date + " </td> <td> " + response.data[i].chosen_emails_1 + " </td> <td> " + response.data[i].chosen_emails_2 + " </td> <td> " + response.data[i].chosen_emails_3 + "</br>");
}
//to prevent (contact-submit) button from submitting form data since submit button has default action of submitting form
$(document).ready(function() {
$('#contact-submit').click(function(e) {
return false;
});
});
}
});
},
error: function(response) {
alert("unable to pull up any service request");
}
});
<button onclick="myfunction();">Go</button>
<div class="tablecontainer" style="display: none;">
<table id="table" border=1>
<tr>
<th> booking_address </th>
<th> booking_date </th>
<th> booking_message </th>
<th>request date and time </th>
<th> requested_tech_1 </th>
<th> requested_tech_2 </th>
<th>requested_tech_3 </th>
<th>xyz</th>
<th>abc</th>
</tr>
</table>
</div>
此行缺少这两个字段周围的<td>
标记,以及整行周围的<tr>
标记。
$("#table").append(response.data[i].user_email + "'>" + response.data[i].booking_number + " </td> <td> " + response.data[i].booking_address + " </td> <td> " + response.data[i].booking_date + " </td> <td> " + response.data[i].booking_message + " </td> <td> " + response.data[i].request_date + " </td> <td> " + response.data[i].chosen_emails_1 + " </td> <td> " + response.data[i].chosen_emails_2 + " </td> <td> " + response.data[i].chosen_emails_3 + "</br>");
你也不应该在那里</br>
- 这甚至不是一个有效的标签,它当然不属于<table>
。
正确的代码是:
$("#table").append("<tr> <td> " + response.data[i].user_email + " </td> <td> " + response.data[i].booking_number + " </td> <td> " + response.data[i].booking_address + " </td> <td> " + response.data[i].booking_date + " </td> <td> " + response.data[i].booking_message + " </td> <td> " + response.data[i].request_date + " </td> <td> " + response.data[i].chosen_emails_1 + " </td> <td> " + response.data[i].chosen_emails_2 + " </td> <td> " + response.data[i].chosen_emails_3 + "</td> </tr>");