日期:2014-05-16 浏览次数:20381 次
<script type="text/JavaScript">
$(function(){
var i=1;
$("#finish").append("点我加载题目");
$("#finish").click(function(){
//$("#finish").hide();
$.getJSON("3php.php",{page:i},function(json){
if(json){
var cnt=json.length;
var str = "";
$.each(json,function(index,array){
var str = "<div class=\"single_item\"><div class=\"element_head\">";
var str =str+"<div class=\"date\">"+array['date']+"</div>";
var str=str+"<div class=\"author\">"+array['author']+"</div>";
var str=str+"<div class=\"content\">"+array['content']+"</div></div></div>";
$("#container").append("我是由服务器加载的题目:"+str);
});
i++;
if(cnt<15){
$("#finish").hide();
$(".nodata").show().html("题目加载完毕");
}else{
}
}
});
});
})
</script>
<div id="container">
<?php
$query=mysql_query("sql语句");
while ($row=mysql_fetch_array($query)) {
echo "我是由数据库加载的题目";
?>
<div class="single_item" id="single_item">
<div id="element_head">
<div class="date"><?php echo $row['1'];?></div>
<div class="author"><?php echo $row['2'];?></div>
<div class="content"><?php echo $row['3'];?></div>
</div>
</div>
<?php } ?>
<center><div id="finish"></div><center>
<div class="nodata"></div>