求jq分页,要那种服务端先调用数据,然后,客户端进行用JQ分页 本帖最后由 niwsmbulai1989 于 2014-01-17 15:11:32 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 搜索一下jquery无刷新分页,就可以找到很多代码。 本例实现 jquery + php 无刷新分页.FF IE 等浏览器均支持index.php<?php header("Content-Type:text/html;charset=utf-8");?><html><head><title>JQ-无刷新分页 by:siyuantlw</title><style>A{text-decoration:none;}A:link {COLOR:#33CCFF;}A:active {COLOR:#FF6666;} A:visited {COLOR:#33CCFF;} A:hover {COLOR:#FF6699; TEXT-DECORATION: underline;position:relative;left:1px;top:1px}</style><script src="jquery-1.5.1.js"></script><script language="javascript"> $(document).ready(function(){ changepage(1); }); function changepage(page){ $.post("sql.php",{page:page},function(data){ $("#test").html(data); }); }</script></head><body> <ul id="test"></ul></body></html>sql.php<?phpmysql_connect("","root","");mysql_select_db("test");mysql_query("set names utf8");if(isset($_POST["page"])){ @$page = max(1, intval($_POST["page"])); $pagesize=10; $startindex=($page-1)*$pagesize; $sql="SELECT * FROM test ORDER BY id LIMIT $startindex,$pagesize"; $rec=mysql_query($sql); while($row=mysql_fetch_array($rec)){ $str.="<li>".$row["uname"]."</li>"; } $num=mysql_num_rows(mysql_query("select * from test")); $pagenum=@ceil($num/$pagesize); for($i=1;$i<=$pagenum;$i++){ if($page==$i){ $str.="<a href='javascript:void(0)' onclick=changepage(".$i.")>[".$i."]</a> "; }else{ $str.="<a href='javascript:void(0)' onclick=changepage(".$i.")>".$i."</a> "; } } echo $str;}else{ die();}?> 那位大哥有wordpress的使用指南之类的东西? a php error are encountered 我想花钱找人做个网站我应该准备什么? 如何实现discuz论坛中添加推特的模块 织梦会员登录后跳转首页的办法 php_file_contents的一个疑惑 是不是百度不喜欢asp的收录还是php成为了主流 weeboxs怎么关闭窗口 phpstorm自动提示,能不能像sublime一样方便 php添加编辑框 按钮 ios推送时,用php做 Joomla 有没有类似防水墙功能的插件
<?php
header("Content-Type:text/html;charset=utf-8");
?>
<html>
<head>
<title>JQ-无刷新分页 by:siyuantlw</title>
<style>
A{text-decoration:none;}
A:link {COLOR:#33CCFF;}
A:active {COLOR:#FF6666;}
A:visited {COLOR:#33CCFF;}
A:hover {COLOR:#FF6699; TEXT-DECORATION: underline;position:relative;left:1px;top:1px}
</style>
<script src="jquery-1.5.1.js"></script>
<script language="javascript">
$(document).ready(function(){
changepage(1);
});
function changepage(page){
$.post("sql.php",{page:page},function(data){
$("#test").html(data);
});
}
</script>
</head>
<body>
<ul id="test"></ul>
</body>
</html>sql.php
<?php
mysql_connect("","root","");
mysql_select_db("test");
mysql_query("set names utf8");if(isset($_POST["page"])){
@$page = max(1, intval($_POST["page"]));
$pagesize=10;
$startindex=($page-1)*$pagesize;
$sql="SELECT * FROM test ORDER BY id LIMIT $startindex,$pagesize";
$rec=mysql_query($sql);
while($row=mysql_fetch_array($rec)){
$str.="<li>".$row["uname"]."</li>";
}
$num=mysql_num_rows(mysql_query("select * from test"));
$pagenum=@ceil($num/$pagesize);
for($i=1;$i<=$pagenum;$i++){
if($page==$i){
$str.="<a href='javascript:void(0)' onclick=changepage(".$i.")>[".$i."]</a> ";
}else{
$str.="<a href='javascript:void(0)' onclick=changepage(".$i.")>".$i."</a> ";
}
}
echo $str;
}else{
die();
}
?>