<script>
//无刷新分页
$("#list a").live('click',function(){var id = $(this).attr('page');
//alert(id);
$.ajax({
type: "get",
url: "index.php",
data: "page="+id,
dataType:"json",
success: function(msg){
//alert( "Data Saved: " + msg.link );
$("#list").html(msg.link);
var nr = '';
for(var i = 0;i<msg.rows.length;i++){
nr +='<li class="pagetr_'+msg.rows[i].id+'">';
nr +='<div class="left_pic"><img src="images/people_1.jpg" title="people" alt="people" /></div>';
nr +='<div class="right_text">';
nr +=' <div class="post_title"><span class="author">'+msg.rows[i].name+'</span><span class="right_text">'+msg.rows[i].time+'</span></div>';
nr +=' <div class="post_info">'+msg.rows[i].content+'</div>';
}
$("#trid").html(nr);
}
});
return false;
})
//留言
$("#message_form").live('submit',function(){
var names = $("#user_name").val();
var content = $("#text").val();
//alert(content);return false;
$.ajax({
type: "post",
url: "add.php",
data: "names="+names+"&content="+content,
dataType:"json",
success: function(msg){
// alert( "Data Saved: " + msg );
if(msg){
var nr = '';
for(var i = 0;i<msg.rows.length;i++){
nr +='<li class="pagetr_'+msg.rows[i].id+'">';
nr +='<div class="left_pic"><img src="images/people_1.jpg" title="people" alt="people" /></div>';
nr +='<div class="right_text">';
nr +=' <div class="post_title"><span class="author">'+msg.rows[i].name+'</span><span class="right_text">'+msg.rows[i].time+'</span></div>';
nr +=' <div class="post_info">'+msg.rows[i].content+'</div>';
}
$("#trid").html(nr);
$("#list").html(msg.link);
}
}
});
return false;
})
//留言人验证
$('#user_name').blur(function(){
var reg = /[\u4e00-\u9fa5\uf900-\ufa2d\w0-9]/;
var name = $(this).attr('value');
if(!reg.test(name)){
$('#nameFont').html('<font color = "red">留言人不能为空</font>');
return false;
}else{
$('#nameFont').html('');
}
});
//留言内容验证
$('#text').blur(function(){
var content = $(this).attr('value');
if(content.length <= 0){
$('#contentFont').html('<font color = "red">留言不能为空</font>');
return false;
}else{
$('#contentFont').html('');
return false;
}
});
</script>