$(document).ready( function(){
$contentLoadTriggered = false;
$("#mainDiv").scroll(function(){
if($("#mainDiv").scrollTop() >= ($("#wrapperDiv").height() -
$("#mainDiv").height()) && $contentLoadTriggered == false)
$contentLoadTriggered == false)
{
$contentLoadTriggered = true;
$.ajax({
type: "POST",
url: "LoadOnScroll.aspx/GetDataFromServer",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (msg) {
$("#wrapperDiv").append(msg.d);
$contentLoadTriggered = false;
},
error: function (x, e){
alert("The call to the server side failed. " +
x.responseText);
}
}
);
}
}
);
}
);

  

var range = 50;             //距下边界长度/单位px
var totalheight = 0;
var num ={$data|count};
var is_load =true;
var main = $("#con"); //主体元素
$(window).scroll(function(){
var srollPos = $(window).scrollTop(); //滚动条距顶部距离(页面超出窗口的高度)
totalheight = parseFloat($(window).height()) + parseFloat(srollPos);
if(($(document).height()-range) <= totalheight && is_load == true) {
if(num < 5 ){
return false;
}
is_load = false;
$("#loading").show();
//alert("0000");
$.ajax({
url : '{:u("Index/post_json")}',
type : 'post',
data : {"num":num,"sch_time":sch_time,"city_from":city_from,"city_dst":city_dst},
dataType : 'json',
success : function(msg) {
//alert(msg);
$("#loading").hide();
myobj=eval(msg); if(num == myobj['nums']){
alert("已经没有新订单了");
is_load = false; //停止加载
return false;
}else{
num=myobj['nums'];
}
myobjs=myobj['data'];
for(var i=0;i<myobjs.length;i++){
ht='<div class="trip_li">';
ht+='<img class="hot" src="__ROOT__/Public/images/icon_hot.png">';
if(myobjs[i]['fleet'].join_uf == 1){
ht+='<img class="uf" src="__ROOT__/Public/images/icon_uf.png">';
}
ht+='<button type="button" class="bespoke" onclick=javascript:window.location.href="'+"{:u('Index/order')}"+'/scid/'+myobjs[i].id+'">立即预约</button>';
ht+='<dl>';
ht+='<dt><font>'+myobjs[i].from_city+'</font> <img src="__ROOT__/Public/images/icon_go.png" /> <font>'+myobjs[i].dst_city+'</font></dt>';
ht+='<dd>发车时间:<i class="times">'+myobjs[i].sch_time+'</i></dd>';
ht+='<dd>车型:'+myobjs[i]['fleet'].best_car+'</dd>';
ht+='<dd><i class="red">¥'+myobjs[i].money+'</i> <i class="red">空位数: '+myobjs[i].used+'/'+myobjs[i].seat+'</i> </dd>';
ht+='</dl>';
ht+='</div>';
//alert(ht);
main.append(ht); }
is_load =true; //恢复加载功能 }
}); }
});

最新文章

  1. jpa+springdata
  2. Class.forName()的作用
  3. python-study1 in hubei
  4. jq
  5. Longest Substring Without Repeating Characters(Difficulty: Medium)
  6. HDU 4578 Transformation --线段树,好题
  7. 能发送http请求(get,post)的工具
  8. C#有关 字符串方法的使用
  9. Swift的闭包(二):捕获值
  10. 百度ueditor 上传图片后如何设置样式
  11. Android 为应用添加数字角标
  12. Cocos2d-x3.0 DrawNode吸取
  13. Windows7下pip源配置修改
  14. MySQL--当mysqldump --single-transaction遇到alter table(2)
  15. 团队作业八-Beta版本冲刺计划及安排
  16. 【最短路+最大流】上学路线@安徽OI2006
  17. Generalized normal distribution and Skew normal distribution
  18. Ubuntu 12.04 安装最新版本NodeJS
  19. RabbitMQ---2、介绍
  20. hasOwnProperty()函数

热门文章

  1. Java for LeetCode 109 Convert Sorted List to Binary Search Tree
  2. 剑指Offer:把数组排成最小的数【45】
  3. 解决/usr/bin/ld: cannot find -lmysqlclient错误
  4. Android WiFi系统【转】
  5. hiho一下 第四十七周 拓扑排序一 【静态数组链式前向星存储结构实现 + 拓扑跳出 】
  6. 9.2 NOIP提高组试题精解(1)
  7. Python中出现“TabError: inconsistent use of tabs and spaces in indentation”问题的解决
  8. L84
  9. listen 70
  10. C语言的内存四区模型和函数调用模型