$(function(){
$.ajax({
type: 'GET', //通过get方式发送请求
url: 'mood.php', //目标地址
cache: false, //不缓存数据,注意文明发表心情的数据是实时的,需将cache设置为false,默认是true
data: 'id=1', //参数,对应文章或帖子的id,本例中固定为1,实际应用中是获取当前文章或帖子的id
dataType: 'json', //数据类型为json
error: function(){
alert('出错了!');
},
success: function(json){ //请求成功后
if(json){
$.each(json,function(index,array){ //遍历json数据列
var str = "<li><span>"+array['mood_val']+"</span><div class="pillar"
style="height:"+array['height']+"px;"></div><div class="face"
rel=""+array['mid']+""><img src="images/"+array['mood_pic']+"">
<br/>"+array['mood_name']+"</div></li>";
$("#mood ul").append(str); //将数据加入到#mood ul列表中
});
}
}
});
...
});
$(".face").live('click',function(){ //侦听点击事件
var face = $(this);
var mid = face.attr("rel"); //对应的心情id
var value = face.parent().find("span").html();
var val = parseInt(value)+1; //数字加1
//提交post请求
$.post("mood.php?action=send",{moodid:mid,id:1},function(data){
if(data>0){
face.prev().css("height",data+"px");
face.parent().find("span").html(val);
face.find("img").addClass("selected");
$("#msg").show().html("操作成功").fadeOut(2000);
}else{
$("#msg").show().html(data).fadeOut(2000);
}
});
});
CREATE TABLE IF NOT EXISTS `mood` ( `id` int(11) NOT NULL, `mood0` int(11) NOT NULL DEFAULT '0', `mood1` int(11) NOT NULL DEFAULT '0', `mood2` int(11) NOT NULL DEFAULT '0', `mood3` int(11) NOT NULL DEFAULT '0', `mood4` int(11) NOT NULL DEFAULT '0', `mood5` int(11) NOT NULL DEFAULT '0', `mood6` int(11) NOT NULL DEFAULT '0', `mood7` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `mood` (`id`, `mood0`, `mood1`, `mood2`, `mood3`, `mood4`, `mood5`, `mood6`, `mood7`) VALUES(1, 8, 6, 20, 16, 6, 9, 15, 21);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有