这是分页的简单代码。并在两个选项卡中用于两个不同的表。
<script>
$(".clik_for_fetch").click(function(){
var request={ id: $(this).attr('fetch_id') };
$.ajax({
url:"pro/userlist.php",
data:request,
dataType:"html",
type:'POST',
beforeSend: function(){
},
success:function(result){
$("#MyId tbody ").html(result);
},
complete: function(){
}
});
});
</script>
如何获取 ID 以动态显示此行
$("#MyId tbody ").html(result);
var request={ id: $(this).attr('fetch_id') };
HTML 代码:tab1
<table class="table table-striped" id="usertable">
</table>
和号码包
<li><a href="#" class="clik_for_fetch" fetch_id1="'.$i.'">'.$i.'</a></li>'
选项卡2
<table class="table table-striped" id="grouptable"
</table>
和号码包
<li><a href="#" class="clik_for_fetch" fetch_id2="'.$i.'">'.$i.'</a></li>'
编辑:这是 HTML 代码
<div class="bs-example bs-example-tabs">
<ul id="myTab" class="nav nav-tabs">
<li class="active"><a href="#userslist" data-toggle="tab" > userlist </a></li>
<li><a href="#usergroups" data-toggle="tab"> usergroups </a></li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="userslist">
<table class="table table-striped" id="usertable">
<thead>
<tr>
<th> ID </th>
<th> name </th>
<th> username </th>
<th style="width: 36px;"> edit </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<hr>
<ul class="pagination" id="pagination">
<?php
while($total_rows_user > 0)
{
echo '<li><a href="#" class="clik_for_fetch" fetch_id1="'.$i.'">'.$i.'</a></li>';
$i++;
$total_rows_user--;
}
?>
</ul>
</div>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade in " id="usergroup">
<table class="table table-striped" id="grouptable">
<thead>
<tr>
<th> ID </th>
<th> name </th>
<th> username </th>
<th style="width: 36px;"> edit </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<hr>
<ul class="pagination" id="pagination">
<?php
while($total_rows_group > 0)
{
echo '<li><a href="#" class="clik_for_fetch" fetch_id2="'.$i.'">'.$i.'</a></li>';
$i++;
$total_rows_group--;
}
?>
</ul>
</div>
</div><!--End tab-->
<script>
$(".clik_for_fetch").click(function(){
var request={ id: $(this).attr('fetch_id') };
$.ajax({
url:"pro/userlist.php",
data:request,
dataType:"html",
type:'POST',
beforeSend: function(){
},
success:function(result){
$("#MyId tbody ").html(result);
},
complete: function(){
}
});
});
</script>
代码由两个不同选项卡中的两个表组成,见下 图
每个表都有一个单独的 id 以及页数