佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > AJAX分頁(yè)效果簡(jiǎn)單實(shí)現(xiàn)

AJAX分頁(yè)效果簡(jiǎn)單實(shí)現(xiàn)

熱門標(biāo)簽:阿里云 Mysql連接數(shù)設(shè)置 服務(wù)器配置 銀行業(yè)務(wù) 科大訊飛語(yǔ)音識(shí)別系統(tǒng) 團(tuán)購(gòu)網(wǎng)站 電子圍欄 Linux服務(wù)器

最近寫一個(gè)給用戶組添加角色的功能,要求一邊是未添加的角色,一邊是已添加的角色,還有搜索功能, 點(diǎn)擊添加后,ajax保存操作.

考慮功能為待查詢功能分頁(yè) , 下方分頁(yè)條, 一共有 2*2 ,4個(gè)ajax…

JS代碼如下:

$(document).ready(function() {
  App.init();
  currentRole(); // 當(dāng)前角色
  currentRolePage();//當(dāng)前角色分頁(yè)
  noAddRole(); //未添加角色
  noAddRolePage();//未添加角色分頁(yè)
 });

//當(dāng)前角色列表
function currentRole(){
  var currentRoleCheckName =$("#currentRoleCheckName").val();
  // 當(dāng)前角色的list集合
  $.ajax({
  async:true, 
  type:"POST", 
  //date:"groupId=rose",//發(fā)送到服務(wù)器的數(shù)據(jù)
  url:"${ctx}/group/ajax_showRolesForGroup.do",//請(qǐng)求路徑
  data:{"groupId":groupId, 
  "page":page1,
  "checkName":currentRoleCheckName
  },
  dataType:"json", //返回?cái)?shù)據(jù)的類型
  success:function(data){ //成功響應(yīng)后的回調(diào)函數(shù)
  var result =data.pageSupport.items;
  console.log(data.pageSupport)
  var s="";
  for(var i in result){ 
   s+="tr class='odd gradeX'>td>"+result[i].name+"/td>"
   +"td>"+result[i].remark+"/td>"
   +"td>button type='button' class='btn btn-xs btn-info m-r-5' onclick='to_RemoveRoleToGroup("+result[i].roleId+");'>移除/button>/td>/tr>";
  }
  $("#currentRole").html(s);

  }

 });
 }

//當(dāng)前角色的分頁(yè)
 function currentRolePage(){
  var currentRoleCheckName =$("#currentRoleCheckName").val();
  var totalPage=0;
  $.ajax({
  async:true, 
  type:"POST", 
  //date:"groupId=rose",//發(fā)送到服務(wù)器的數(shù)據(jù)
  url:"${ctx}/group/ajax_showRolesForGroup.do",//請(qǐng)求路徑
  data:{"groupId":groupId, 
  "page":page1,
  "checkName":currentRoleCheckName
  },
  dataType:"json", //返回?cái)?shù)據(jù)的類型
  success:function(data){ //成功響應(yīng)后的回調(diào)函數(shù)
  totalPage=data.pageSupport.last;
  console.log(totalPage)
  var i= 0;
  var a="";
  for( i=page1-2; i=page1+2;i++){
  if(i>0  i=totalPage){
   if(i == 1){
   $("#prev1").attr('class','disabled'); 
   }
   if(page1 == i){
   a+="li class='active' bs1='" + i + "'>a>"+i+"/a>/li>";
   }else{
   a+="li class='zhong1' bs1='" + i + "'>a href='javascript:void(0);' onclick='a_method("+i+");' >"+i+"/a>/li>";
   }

  }
  }

  $("#fy_list").html(a);
  }

 });

 }
 //中間頁(yè) 
 function a_method(i) {
  page1 = i;
  currentRole(); // 當(dāng)前角色
  currentRolePage();//當(dāng)前角色分頁(yè)
 }

//查詢操作
function currentRoleCheck(){
 page1=1;
 currentRole(); // 當(dāng)前角色
 currentRolePage();//當(dāng)前角色分頁(yè)
 }

HTML代碼如下:

!-- 兩個(gè)相同的DIV 下面只是一個(gè)-->
div class="panel-body col-md-6">
 div style="border: 1px solid #E0E0E0;border-radius: 4px">
 div class="panel-heading " style="background-color:#E0E0E0; ">

  h2 class="panel-title">b>已選角色/b>/h2>
 /div>
 div id="firstCheck" class="panel-body">
   div style="padding-left: 0 !important;" id="firstCheck" class="panel-body">
    form class="form-inline" method="POST" >
    div class="form-group m-r-10">
     input id="currentRoleCheckName" type="text" class="form-control" placeholder="角色名稱" name="fname" maxlength="40" />
    /div>
  div class="checkbox m-r-10">
   /div>
 button id="currentCheck"type="button" class="btn btn-sm btn-primary m-r-5" onclick="currentRoleCheck()" >查詢/button>
  /form>
   /div>
   div >
   table id='data-table' class='table table-bordered' >
   thead>
     tr>
     th>角色名稱/th>
     th>備注信息/th>
     th>操作/th>
     /tr> 
   /thead>
   tbody id="currentRole">
    !--
    當(dāng)前用戶組已有角色list
   -->

   /tbody>
   /table>
   /div>
    div class="buttonBox">

    div align="right">
    ul id="fy_list" class="pagination pagination-sm m-t-0 m-b-10 ">

    /ul>
    /div> 
    /div> 

  /div>

 /div>
/div>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • 用jQuery中的ajax分頁(yè)實(shí)現(xiàn)代碼
  • JQuery+Ajax無(wú)刷新分頁(yè)的實(shí)例代碼
  • jQuery Pagination Ajax分頁(yè)插件(分頁(yè)切換時(shí)無(wú)刷新與延遲)中文翻譯版
  • Ajax讀取數(shù)據(jù)之分頁(yè)顯示篇實(shí)現(xiàn)代碼
  • php,ajax實(shí)現(xiàn)分頁(yè)
  • JS+Ajax+Jquery實(shí)現(xiàn)頁(yè)面無(wú)刷新分頁(yè)以及分組 超強(qiáng)的實(shí)現(xiàn)
  • jQuery DataTables插件自定義Ajax分頁(yè)實(shí)例解析
  • 使用PHP+JQuery+Ajax分頁(yè)的實(shí)現(xiàn)
  • php+ajax實(shí)現(xiàn)無(wú)刷新分頁(yè)的方法
  • 基于Jquery+Ajax+Json的高效分頁(yè)實(shí)現(xiàn)代碼

標(biāo)簽:衡水 棗莊 萍鄉(xiāng) 大理 蚌埠 廣元 江蘇 衢州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《AJAX分頁(yè)效果簡(jiǎn)單實(shí)現(xiàn)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    阿图什市| 芦山县| 什邡市| 肇东市| 苏州市| 郯城县| 吉木乃县| 十堰市| 建阳市| 襄垣县| 浦县| 启东市| 安康市| 阿拉善右旗| 习水县| 东城区| 大丰市| 潮州市| 涿鹿县| 化德县| 淄博市| 莱西市| 泸定县| 洞口县| 西峡县| 仁化县| 边坝县| 南丰县| 东平县| 闽清县| 广平县| 平和县| 西乌珠穆沁旗| 东海县| 宁城县| 大足县| 乐业县| 铁力市| 宜章县| 贡觉县| 曲靖市|