Pagina 1 din 1
modificare load more...
Scris: Lun Noi 21, 2011
de trif
salut, am codul acesta
Cod: Selectaţi tot
<script type="text/javascript">
$(function()
{
$('.more_updates').live("click",function()
{
var ID = $(this).attr("id");
if(ID)
{
$("#more"+ID).html('<br><center>Se cauta rezultate...</center><br>');
$.ajax({
type: "POST",
url: "loadmore.php",
data: "lastupd="+ ID,
cache: false,
success: function(html)
{
$("#updates").append(html);
$("#more"+ID).remove(); // removing old more button
}
});
}
else
{
$(".morebox").html('<br><center>Sfarsit!</center><br>');// no results
}
return false;
});
});
</script>
care imi preia din loadmore.php datele si mi le afiseaza dar problema este in felul urmator: imi afiseaza date numai daca dau pe "mai multe rezultate" dar eu nu mai vreau ca sa mai mearga prin "
click" ci vreau sa mearga atunci cand ajunge la sfarsit sa se incarce alte date automat. de exemplu cum este pe sitele acesta:
http://torrentbutler.eu/ daca dati in jos se incarca singur nu te streseaza cu clickclick si de alea. daca se poate modifica codul de mai sus m-as bucura ca eu nu stiu. sper ca ati inteles. va rog cine stie va rog sa ma ajutati. va multumesc anticipat. cu stima trif
modificare load more...
Scris: Mar Noi 22, 2011
de nutzu123
Salut trif incearca urmatorul cod, eu l.am incercat si merge
index.php
Cod: Selectaţi tot
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Infinite Scrolling like New twitter</title>
<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script type="text/javascript">
$(window).scroll(function(){
if($(window).scrollTop() == $(document).height() - $(window).height()){
$('div#loadmoreajaxloader').show();
$.ajax({
url: "loadmore.php?lastid=" + $(".postitem:last").attr("id"),
success: function(html){
if(html){
$("#postswrapper").append(html);
$('div#loadmoreajaxloader').hide();
}else{
$('div#loadmoreajaxloader').html('<center>No more posts to show.</center>');
}
}
});
}
});
</script>
<style>
body{ margin:0px; }
#hycusdemosheader{ font-family:Georgia; font-size:30px;border-bottom:1px solid #676767;padding:5px 5px 8px;margin-bottom:10px; }
#idh, #idh:visited { color:#000; text-decoration:none; }
#hycusdemosheader span{ color:#999; }
#downloadbutton{ color:#ffffff;background:#03AEEB;float:right;font-size:20px;padding:5px;-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;text-decoration:none; }
#downloadbutton:hover{ background:#888888; }
#hycucdemosbody{ padding:10px 0; min-height:500px; }
#hycusdemosfooter{ border-top:1px solid #676767; padding:10px; font-size:20px; }
#hycusdemosfooter a{ text-decoration:none; }
#wrapper{
width:600px;
margin:auto;
}
.spacer{
clear:both;
height:5px;
}
.txtarea{
font-size:18px;
height:50px;
width:100%;
}
#postswrapper{
border-bottom:1px dotted #555555;
}
.postitem{
border-top:1px dotted #555555;
padding:10px 5px;
font-size:24px;
}
.postitem:hover{
background:#EFEFEF;
}
#newpostlink{
display:block;text-align:center;border:2px solid #414141;background:#7D7D7D;color:#fff; margin: 0 0 10px;padding:5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px;font-size:20px;text-decoration:none;
}
</style>
</head>
<body>
<div id="hycusdemosheader">Infinite scrolling like New Twitter</span></div>
<div id="hycucdemosbody">
<div id="wrapper">
<div id="postswrapper">
<?php
$dblink = mysql_connect('DB_HOST', 'DB_USERNAME', 'DB_PASSWORD');
mysql_select_db('DB_NAME');
$query = 'SELECT * FROM infinitescrolling ORDER BY id DESC LIMIT 0, 10';
$result = mysql_query($query);
while($rec = mysql_fetch_object($result)) {
echo '<div class="postitem" id="'.$rec->id.'">Post no '.$rec->id.': '.$rec->text.'"</div>';
}
?>
</div>
<div id="loadmoreajaxloader" style="display:none;"><center><img src="ajax-loader.gif" /></center></div>
</div>
</div>
</body>
</html>
loadmore.php
Cod: Selectaţi tot
<?php
$dblink = mysql_connect('DB_HOST', 'DB_USERNAME', 'DB_PASSWORD');
mysql_select_db('DB_NAME');
if($_GET['lastid']){
$query = 'SELECT * FROM infinitescrolling WHERE id < "'.$_GET['lastid'].'" ORDER BY id DESC LIMIT 0, 10';
$result = mysql_query($query);
while($rec = mysql_fetch_object($result)) {
echo '<div class="postitem" id="'.$rec->id.'">Post no '.$rec->id.': '.$rec->text.'"</div>';
}
}
?>
jquery-1.4.4.js
http://www.fileshare.pro/60itj9 descarca aici, si mai modifici tu, depinde cum ai baza de date
modificare load more...
Scris: Vin Noi 25, 2011
de trif
salut, multumesc mult de ajutor. dupa multe batai de cap am reusit sa ii dau de cap. ceea ce conteaza este ca merge. multumesc inca o data. cu stima trif