chizijs Posted December 25, 2010 Report Share Posted December 25, 2010 (edited) Tātad gribu uztaisīt page pagination lai pārlādetu komentāru lapu bez refresh. php daļa if(!isset($_GET['page'])){ $lapa = 1; } else { $lapa = $_GET['page']; } $max_results = 3; $from = (($lapa * $max_results) - $max_results); $c_c = mysql_query("SELECT * FROM c_c WHERE n_id = '".stripslashes($_GET['id'])."' ORDER BY id ASC LIMIT $from, $max_results"); $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM c_c"),0); $total_pages = ceil($total_results / $max_results); if(mysql_num_rows($c_c) == 0){ echo '<div style="width: 460px; height: auto; background: none repeat scroll 0% 0% rgb(255, 255, 255); float: left; margin: 2px; border: 1px solid rgb(221, 221, 221); -moz-border-radius: 3px 3px 3px 3px;"><div style="padding-left: 10px; margin: 0px auto;"><table><tbody><tr><td style="width: 200px;">No comments about <b>'.$row['title'].'</b>.</td></tr></tbody></table></div></div>'; } else { while($c = mysql_fetch_array($c_c)){ $coum = substr_replace($c['com'], '<br/>',65, 66); echo '<div id="comm"> <div class="title"><div style="float: left;"><a href="/?p=user&id='.$c['a_id'].'">'.$c['who'].'</a> @ '.$c['when'].'</div><div style="float: right;"> </div><br style="clear: both;"></div> <div class="text">'.nl2br($coum).'</div></div><br> '; } echo "<br/><table width='100%' align='left'><tr><td><div id='news_container'><div id=\"pages\">"; if($lapa > 1){ $prev = ($lapa - 1); echo '<a href=\'javascript:;\' onclick=\'news_page("'.$prev.'", "")\'>«</a>'; } for($i = 1; $i <= $total_pages; $i++){ if(($lapa) == $i){ echo "<span class=\"current\"><b>".$i."</b></span>"; } else { echo "<a href='javascript:;' onclick='news_page(\"".$i."\", \"\")'>$i</a>"; } } if($lapa < $total_pages){ $next = ($lapa + 1); echo "<a href='javascript:;' onclick='news_page(\"".$next."\", \"\")'>»</a>"; } echo "</div></div></td></tr></table> "; } js daļa function news_page(page, search) { $("#news_container").mask("Loading.."); $.get("/pages/news.php?id=<?php echo $_GET['id']; ?>&page=", { page: page }, function(response){ $("#news_container").html(response); $("#news_container").unmask(); }); } Problēma ir tada - kad spiež uz citu lapu neko neielādē.. Edited December 25, 2010 by chizijs Link to comment Share on other sites More sharing options...
chizijs Posted December 25, 2010 Author Report Share Posted December 25, 2010 neviens? Link to comment Share on other sites More sharing options...
briedis Posted December 25, 2010 Report Share Posted December 25, 2010 varbūt debugo, skaties, kas notiek, kas nē? Kur ir problēma? Baigi jau mums no malas te gribās tādā milzīgā koda blāķī iedziļināties un meklēt problēmu... Ko rāda JS kļūdu konsole? Link to comment Share on other sites More sharing options...
chizijs Posted December 26, 2010 Author Report Share Posted December 26, 2010 Error: $("#news_container").mask is not a function Source File: http://localhost/?p=news&id=1 Line: 23 Link to comment Share on other sites More sharing options...
briedis Posted December 26, 2010 Report Share Posted December 26, 2010 Nu redzi, .mask is not a function. Ko tas nozīmē? Link to comment Share on other sites More sharing options...
daGrevis Posted December 26, 2010 Report Share Posted December 26, 2010 Es zinu! Es zinu!!! xDD Link to comment Share on other sites More sharing options...
Recommended Posts