$(function(){ var lock=false; var i = 1; var dates = $("input[name='dates']").val(); if(dates==undefined||dates==''){ dates = {}; }else{ dates = JSON.parse(dates); } var dlength = dates.length; $s_top = $(this).scrollTop(); //鍒锋柊澶囩敤 //鑾峰彇椤甸潰椤堕儴琚嵎璧锋潵鐨勯珮搴 function scrollTop(){ return Math.max( //chrome document.body.scrollTop, //firefox/IE document.documentElement.scrollTop); } //鑾峰彇椤甸潰鏂囨。鐨勬€婚珮搴 function documentHeight(){ //鐜颁唬娴忚鍣紙IE9+鍜屽叾浠栨祻瑙堝櫒锛夊拰IE8鐨刣ocument.body.scrollHeight鍜宒ocument.documentElement.scrollHeight閮藉彲浠 return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight); } function windowHeight(){ return (document.compatMode == "CSS1Compat")? document.documentElement.clientHeight: document.body.clientHeight; } function jsonajax(){ if (!(scrollTop() + windowHeight() >= (documentHeight() - 150))) { return ; }; if(lock==true){//鍔犱釜閿侊紝閬垮厤娌″姞杞藉畬鍙堝紑濮嬪姞杞 return false; } lock=true; if(i>=dlength){ return false; } var date = dates[i]; url=$("input[name='url']").val(); data={"date":date}; $.ajax({ url:url, type:'POST', data:data, dataType:'json', success:function(json){ if(json.status==1){ $('.cooperhot721_con').append(json.data) i++; lock=false; jsonajax(); } } }); } jsonajax(); $(window).scroll(function(){//婊氬姩鍒扮10绡囨枃绔 jsonajax(); }); });