我想在ajax调用成功后重新放置当前表并显示新表。
这是我现有的表格:
[10, -64, 92, 105, 15, 35, -32, -101, 47, 111, -1, -72, 110, 105, -77, -117, 23, 69, 113, -49, -14, -104, 110, 78, 84, -78, 30, 26, 38, -43, 36, 112, 33, -10, -5, -63, -11, 47, -53, -116, -71, 2, -64, -16, 36, 122, 45, 79, 3, 49, -7, 120, -10, 125, 92, 43, -43, -34, 100, 75, -54, -36, 5, 106, -128, 106, -120, 36, 59, -31, -2, 100, 79, 65, -118, -50, -83, 11, -19, -28, -80, -125, -8, 59, -94, -125, 91, -104, -96, -12, 14, 31, -108, 61, 12, 6, 90, -6, -24, -47, -57, 55, -64, -50, 41, 26, -46, -81, -124, 122, 82, -120, 31, 19, 85, -7, -17, 40, -18, -118, -64, 114, -76, -60, 116, -12, -16, 12, -91, 55, -57, -61, 108, 88, -13, 80, -38, 100, 121, -11, -20, -5, -105, 20, 87, 60, -125, 33, -11, 111, -115, -69, 24, 0, -113, -24, 49, 21, -27, 96, 27, 12, 72, 50, 12, 15, -61, -40, -52, -76, -63, 29, -99, 114, 88, 41, 111, 9, 127, 96, -123, 58, 92, -91, 17, 114, -11, -105, -79, -110, -100, -35, 16, 103, 27, -21, -50, 7, -28, 117, 119, -124, -127, -115, -116, 86, 74, 57, -46, 114, 102, -18, -73, 97, 10, -113, 119, -1, -68, -18, -16, -119, 49, -120, 104, 121, 113, -82, -42, -119, -81, 95, -114, 16, -11, -58, 36, -24, 58, -50, 101, -117, -55, -101, -19, 62, -53, 30, -59, 106, 37, 98, 102, 75, -9, 91]
这是我的脚本:
<div class="container">
<h2 class="well col-lg-4">Booking History</h2>
<table id="tab" class="table table-bordered danger table-hover" style="color:orangered">
<thead>
<tr>
<th>S.N</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Booking Date</th>
<th>Booked On</th>
<th>Vehile Number</th>
<th>Parking Slot no.</th>
</tr>
</thead>
<tbody>
@{ int i = 1;}
@foreach (var item in Model)
{
<tr>
<td>@i</td>
<td>@item.firstName</td>
<td>@item.lastName</td>
<td>@item.email</td>
<td>@DateTime.Parse(item.bookingDate).ToString("dd MMM yyyy")</td>
<td>@DateTime.Parse(item.bookedOn).ToString("dd MMM yyyy")</td>
<td>@item.vehicleNo</td>
<td>@item.parkingSlot_id</td>
</tr>
i++;
}
</tbody>
</table>
<div class="text-center">
@Html.PagedListPager(Model, page => Url.Action("SearchBooking", new { page, fromDate = ViewBag.fromD,toDate= ViewBag.toD }))
</div>
</div>
答案 0 :(得分:0)
尝试
在$("#tab").html('')
之前先使用append table
就像
$("#tab").html('');
$("#tab").append(NewTable);