瀹炵幇Ajax寮傛鐨刲ayui鍒嗛〉

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了瀹炵幇Ajax寮傛鐨刲ayui鍒嗛〉相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/_1__1_' title='++'>++   turn   count()   鑱旂郴   cep   width   rck   evo   info   

鎴戜滑甯哥敤layui鍋氬墠绔殑寰堝涓滆タ锛屾瘮濡傚垎椤电殑瀹炵幇锛屼絾鏄竴鑸兘鏄悓姝ョ殑,杩欐閬囪涓€涓柊鐨勯渶姹傦紝瑕佹眰寮傛鍔犺浇鏁版嵁骞朵笖鍒嗛〉涔熸槸寮傛鐨勶紝瑙e喅鎬濊矾鏄湪鍏堟妸寮傛鍔犺浇鏁版嵁鏂规硶鍒嗙鐢ㄨ嚜瀹氫箟鍑芥暟鍑烘潵锛屽厛璋冪敤鑷畾鐨勬柟娉曞紓姝ュ姞杞芥暟鎹畬鎴愬悗鍐嶈繘琛屽垎椤碉紝鐒跺悗鍦ㄥ垎椤甸噷鍐嶆璋冪敤鍔犺浇鏁版嵁鏂规硶銆傘€?/p>

椤甸潰鏁堟灉鍥?/p>

鎶€鏈垎浜浘鐗? src=

椤甸潰浠g爜

-

        <div class="rctj-box ${(detailflg==鈥榙etailflg鈥??鈥樷€?鈥榣ayui-hide鈥榼 ">
            <div style="margin-top: 25px">浜烘墠鎺ㄨ崘</div>
            <div class="rctj"  style="margin-top: 10px;padding: 20px;background-color: #F2F2F2;" > 
                 <table class="layui-table">
                      <colgroup>
                        <col width="150">
                        <col width="200">
                        <col>
                      </colgroup>
                      <thead>
                        <tr id="rckth">
                          <th style="text-align:center">濮撳悕</th>
                          <th style="text-align:center">瀛﹀巻</th>
                          <th style="text-align:center">鎶€鑳?span style="color: #0000ff"></th>
                          <th style="text-align:center">缁忛獙</th>
                          <th style="text-align:center">浣忓潃</th>
                          <th style="text-align:center">鑱旂郴鏂瑰紡</th>
                        </tr> 
                      </thead>
                      <tbody id="rcktb">
                       <%--  <tr>
                          <td> </td>
                          <td>${res}</td>
                          <td>${data}</td>
                          <td>浜庡崈涓囧勾涔嬩腑</td>
                          <td>鏃堕棿鐨勬棤娑殑鑽掗噹閲屸€?/span></td>
                          <td>鏃堕棿鐨勬棤娑殑鑽掗噹閲屸€?/span></td>
                        </tr> --%>
                      </tbody>
                    </table>
             </div>
                    <div id="pagefenye" class="fenye" style="text-align:center;"></div>
         </div>  

js浠g爜

-

//鍔犺浇瀹屾垚
$(function(){    
                  var sherchkey=鈥?{positioninfo.name}鈥?span style="color: #000000">;
                  savePosition();//淇濆瓨淇敼鏂规硶
                  getPeopleList(1,5,sherchkey);//鑾峰彇浜烘墠鍒楄〃 
                 // getPageList(); //鍒嗛〉鏂规硶
       });


//鑷繁灏佽鑾峰彇鏁版嵁鏂规硶
function getPeopleList(crr,lmt,searchKey){
                //鑾峰彇浜烘墠鍒楄〃
                 $.ajax({
                          url:鈥?{ctx}/recruit/peoplelist鈥?span style="color: #000000">,
                          type:鈥榩ost鈥?span style="color: #000000">,
                          data:{
                                 "curr":crr||1,
                                 "pageSize":lmt||5,
                                 "searchKey":searchKey
                               },
                          dataType:鈥榡son鈥?span style="color: #000000">,
                          success:function(res){
                              if(res.success=="success"){
                                  console.log(res);
                                  count=res.data.totalElements;//鎬昏褰?/span>
                                  curr=res.data.number; //褰撳墠椤?/span>
                                  limit=res.data.size; //姣忛〉鍑犱釜
                                  var rclist=res.data.content;
                                  var html=鈥樷€?span style="color: #000000">;
                                  var len=rclist.length;
                                  
                                  for (var i=0; i<len; i++){
                                      var htmlbuf=鈥?lt;tr>鈥?
                                         鈥?lt;td style="text-align:center">鈥?rclist[i].name+鈥?lt;/td>鈥?
                                         鈥?lt;td style="text-align:center">鈥?rclist[i].edu+鈥?lt;/td>鈥?
                                         鈥?lt;td style="text-align:center">鈥?rclist[i].skill+鈥?lt;/td>鈥?
                                         鈥?lt;td style="text-align:center">鈥?rclist[i].exp+鈥?lt;/td>鈥?
                                         鈥?lt;td style="text-align:center">鈥?rclist[i].add+鈥?lt;/td>鈥?
                                         鈥?lt;td style="text-align:center">鈥?rclist[i].tel+鈥?lt;/td>鈥?
                                         鈥?lt;/tr>鈥?span style="color: #000000">;
                                       html=html+htmlbuf; 
                                  }
                                  $("#rcktb").html(html);
                                  //璋冪敤鍒嗛〉鏂规硶
                                  getPageList(count,curr,limit,searchKey);
                                   
                              }else {
                                  layer.alert(res.message);
                              }
                          },
                          error:function(){
                              layer.msg("缃戠粶鏁呴殰");
                          }
                      })
}


//鑷繁灏佽鍒嗛〉鏂规硶
function getPageList(count,curr,limit,searchKey){
               //鍒嗛〉鏂规硶
                layui.use([鈥榣aypage鈥? 鈥榣ayer鈥榏, function(){
                  var laypage = layui.laypage
                  ,layer = layui.layer;
                  //瀹屾暣鍔熻兘
                  laypage.render({
                    elem: 鈥榩agefenye鈥?span style="color: #000000">,
                    count: count||0,
                    theme: 鈥?009587鈥?span style="color: #000000">,
                    limit : limit||3,
                    limits:[5, 10, 20, 30, 40],
                    curr : curr||1,
                    layout: [鈥榗ount鈥? 鈥榩rev鈥? 鈥榩age鈥? 鈥榥ext鈥?  鈥榬efresh鈥? 鈥榮kip鈥?span style="color: #000000">],
                    jump: function(obj,first){
                    //debugger;
                        if(!first){
                            //window.location.href = "?curr="+obj.curr+"&pageSize="+obj.limit+"&enterId="+鈥?{enterId}鈥?
                            getPeopleList (obj.curr,obj.limit,searchKey);
                        }
                    }
                  });
                });
}

鍚庡彴浠g爜

-

/**
     * 浜烘墠鍒楄〃
     * @param curr
     * @param pageSize
     * @param searchKey
     * @param enterId
     * @param model
     * @return
     */
    @RequestMapping("/peoplelist")
    @ResponseBody
    public ResultEntity peopleList(@RequestParam(value = "curr", defaultValue = "1") int curr,
            @RequestParam(value = "pageSize", defaultValue = "5") int pageSize,String searchKey,Model model){
     
        ResultEntity res = new ResultEntity();
        try {
            PageUtils pageUtils = new PageUtils(curr, pageSize, "", "");
            Page<List<Map<String, Object>>> list = recruitService.getPeopleList(searchKey, pageUtils);
            List<Map<String, Object>> dataList = (List<Map<String, Object>>) list.getData();
            PageVo pageVo = new PageVo(list.getCurrentPageNo() - 1, dataList, pageSize, list.getTotalPageCount(),
                    list.getTotalCount());
            pageVo.setNumber(curr);
            res.setData(pageVo);
            //res.setData(curr);
            //res.setData(enterId);
            res.setSuccess("success");
            res.setMessage("鑾峰彇鎴愬姛");
        } catch (Exception e) {
            e.printStackTrace();
            res.setSuccess("false");
            res.setMessage("鑾峰彇澶辫触");
        }
        return res;
        
        
    }

 

以上是关于瀹炵幇Ajax寮傛鐨刲ayui鍒嗛〉的主要内容,如果未能解决你的问题,请参考以下文章

[PHP] layui瀹炵幇澶氬浘涓婁紶锛屽浘鐗囪嚜鐢辨帓搴忥紝鑷敱鍒犻櫎

涓€涓猘jax瀹炵幇琛ㄥ崟涓婁紶鏂囦欢鐨勭鍣?formdata

瀹炵幇strcpy

018 瀹炵幇鍟嗗搧鍒嗙被鏌ヨ

webpack loader 瀹炵幇

绾挎€ц〃閾捐〃瀹炵幇