Copyright @ 2015-2024 织梦园 版权所有 Power by DedeCms
鲁ICP备15039853号-2

模板标签 TAG标签 网站地图 XML地图 今日更新 返回顶部
$(document).ready(function (e) { var url='/api.php/do/likes/id/'+{content:id}; $.ajax({ type: 'POST', url: url, dataType: 'json', data: { appid: '{pboot:appid}', timestamp: '{pboot:timestamp}', signature: '{pboot:signature}' }, success: function (response, status) { if(response.code){ //获取数据成功 //此处对页面已经显示的{content:likes}+1,注意JS中需要转换为数字,才能进行+1,否则会是字符串拼接。 alert(response.data); }else{ //返回错误数据 alert(response.data); } }, error:function(xhr,status,error){ //返回数据异常 alert('返回数据异常!'); } }); }); |
// 点赞 public function likes() { if (! ! $id = request('id', 'int')) { if(! cookie('likes_' . $id)){ $this->model->addLikes($id); cookie('likes_' . $id, true, 86400, null, null, null, null); json(1, '点赞成功'); }else{ json(0, '24小时内只能点赞一次哦!'); } } else { json(0, '点赞失败'); } } |