Grasp.Today

瀑布流

JS:

  

function ajaxLoad(tag){
  Url = '{:U('news/Kr/moreKr')}'
  $.get(Url,{tag:tag},function(msg){
    if(msg !=null){
      msgLength = msg.length ;
      for (var i=0;i<msgLength;i++)
      {
        str = msg[i];
        var div1 = $("#div1").height();
        var div2 = $("#div2").height();
        var div3 = $("#div3").height();
        var div4 = $("#div4").height();
        var minDiv = Math.min(div1,div2,div3,div4);
        var k = 0;
        for (var n = 0; n < 5 ; n++) {
          if($("#div"+n).height()==minDiv && k<1){
            $("#div"+n).append(str);
            k = 1; 
          }
        };
      }
    }
      //分页代码显示
      $("#page").show();
   },'json');
}
var flag = 0;
var winH = $(window).height();  
$(window).scroll(function () { 
  var pageH = $(document.body).height(); //页面总高度  
  var scrollT = $(window).scrollTop(); //滚动条top  
  if(winH + scrollT > pageH-50){
    if(flag<1 && p < 2 ){
      ui.showMessage('正在加载',0,0.5);
      ajaxLoadMoreKr({$Think.get.id})
      flag = 1;
    }
  }
});

 PHP:

  

public function Abc(){
    $id = $_GET['tag'];
    $perNum =5;
    $start =$perNum+1;
    if($id){
        //$sql = "select title from ts_kr_link where status > 0 and FIND_IN_SET(".$id." , `tags` ) order by cTime desc limit ".$start.",".$perNum;
    }else{
        $sql = "select a.title,a.description,a.link,b.save_path,b.save_name from ts_kr_link a ,ts_attach b where a.logo = b.attach_id limit ".$start.",".$perNum;
    }
    $res = M()->query($sql);
    foreach($res as $k => $v){
        $data[$k] = '<div class="module"><dl><dt><a href="'.text($res[$k]['link']).'"><img src="'.SITE_URL.'/data/upload/'.$res[$k]['save_path'].'/'.$res[$k]['save_name'].'" width="180" height="50" /></a></dt><dd><a href="'.text($res[$k]['link']).'">'.text($res[$k]['title']).'</a></dd><p>'.msubstr(text($res[$k]['description']),0,200).'</p></div>';
    }
    echo json_encode($data);
}

  

   

posted @ 2013-07-29 16:39  gaohj  阅读(207)  评论(0编辑  收藏  举报