您好我有問題,改變HTML內容,這是由AJAX如何改變的Ajax生成的HTML內容
產生這是網頁的代碼:
@model IEnumerable<WE_SRW_PeerNissen.Models.Reservations>
@{
ViewBag.Title = "List";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Übersicht Liste</h2>
<form method="post" action="List">
<div class="input-group">
<div class="input-group-btn">
<input type="text" class="form-control" name="searchbar" placeholder="Search">
<button class="btn btn-default" type="submit">
<i class="glyphicon glyphicon-search"></i>
</button>
</div>
</div>
</form>
<table class="table" id="sorttable">
<thead bgcolor="white">
<tr>
<th>
@Html.DisplayNameFor(model => model.BookingNr)
</th>
<th>
@Html.DisplayNameFor(model => model.Arrival)
</th>
<th>
@Html.DisplayNameFor(model => model.Departure)
</th>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Appartment)
</th>
<th>
@Html.DisplayNameFor(model => model.Adult)
</th>
<th>
@Html.DisplayNameFor(model => model.Children)
</th>
<th>
@Html.DisplayNameFor(model => model.Total)
</th>
</tr>
</thead>
</table>
<link href="~/Content/DataTables/css/jquery.dataTables.min.css" rel="stylesheet" />
<script src="~/Scripts/DataTables/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
$('#sorttable').DataTable({
"ajax": {
"url": "/OverView/loaddata",
"type": "GET",
"datatype": "json"
},
"columns": [
{ "data": "BookingNr", "autoWidth": true },
{ "data": "Arrival", "autoWidth": true },
{ "data": "Departure", "autoWidth": true },
{ "data": "Name", "autoWidth": true },
{ "data": "Appartment", "autoWidth": true },
{ "data": "Adult", "autoWidth": true },
{ "data": "Children", "autoWidth": true },
{ "data": "Total", "autoWidth": true },
]
});
});
</script>
會產生什麼樣的一個例子:
<div class="dataTables_filter" id="sorttable_filter">
<label>Search:
<input aria-controls="sorttable" type="search" placeholder="">
</label>
</div>
我認爲這是我最好的嘗試:
<script>
$(document).ready(function() {
$(document).on(function() {
$('#sorttable_filter label:eq(1)').text('Suchen:');
});
});
</script>
我設定的AJAX腳本下面,我也試圖把它放在下同腳本標籤以確保,即AJAX執行
datatable有一個設置對象,您可以通過它指定它顯示的按鈕文本。閱讀數據表手冊。關於你的jQuery選擇器失敗的原因 - 當代碼執行時,你所指定的元素很可能不存在於DOM中。就像我說的,閱讀數據表格文檔。 –
當你使用'on(...)'時,你是不是錯過了事件參數? – moopet
我對java和jQuery,AJAX很新。我對C#沒什麼不好,對於一個學生。我必須使用java,jquery,AJAX一次,但我想了解更多。 – peni4142