52,797
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="jquery.js" type="text/javascript"></script>
<title></title>
</head>
<body>
<div id="showdata"></div>
<!-- 点击一次,value值变化一次 -->
<input type="hidden" id="currentresult" value="1" />
<button id="show">Load</button>
<script type="text/javascript">
$(document).ready(function(){
$(document).on('click','#show',function(e){
var pageno = $('#currentresult').val();
$.get("getajax.php","page="+pageno ,function(data){
pageno++;
$('#currentresult').val(pageno);
$('#showdata').append(data);
});
});
});
</script>
</body>
</html>
<!-- This is ajax data. -->
<?php
$con = mysqli_connect("localhost", "root", "", "maroon5");
$page=isset($_GET["page"])?$_GET["page"]:0;
$pageNo = $page;
$startLimit = ($pageNo-1)*2;
$query = "SELECT * from tour LIMIT $startLimit,2 ";
$result = mysqli_query($con,$query);//如果查询失败,则返回false
var_dump($result);
while($row = $result -> fetch_assoc()){
?>
<div>
<h4>month:<?php echo $row["month"]; ?>day:<?php echo $row["day"]; ?></h4>
</div>
<?php
}
?>
$.ajax({
type:"get",
data:"page="+pageno,
dataType:"返回的数据类型",
error:function(){
},
success:function(){
}
})
for(var i=0;i<2;i++){
$.get("getajax.php","page="+i,function(data){
pageno++;
$('#currentresult').val(pageno);
$('#showdata').append(data);
});
}
var pageno=1;
console.log("page="+pageno); //输出 page=1