营蜂创意营销 营蜂创意营销
  • 营蜂首页
  • 交流分享
    • 品牌营销
    • 灵感创意
    • 设计技巧
    • IT开发
  • 营销自助
    • 新闻发布
    • 排名优化
    • 软文外链
    • 永久主机
  • 资源推荐
    • 软件
    • 素材
    • 工具
  • 关于我们
营蜂创意营销 营蜂创意营销
  • 品牌营销
  • 灵感创意
  • 设计技巧
  • IT开发
Pbootcms ajax 无刷新点赞
  • 作者:admin
  • 分类:IT开发
  • 发布时间:2020-03
  • Tags:
PbootCMSCMS

先引入 jq 文件

<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

无须使用 API,

把以下代码放入合适的位置即可,可自定义 css


<button class="support">点赞</button>  <!--按钮--->



<div id="support_number">{content:likes}</div>  <!--赞数量-->



<p class="supported"></p>   <!--已赞提示-->



<!--ajax-->



<script>



$('.support').on('click',  //绑定事件



function() {

$.ajax({

url: '{content:likeslink}',  //点赞链接

data: {

'likes': 'likes'

},

success: function(data) {

$('#support_number').load(location.href + " #support_number");  //点赞后刷新#support_number

if (data.state) {} else {

$(".supported").html("已点赞!")  //已赞提示

}},

error: function(xhr, status, error) {

console.log(error)

}

});

})



</script>



上一条:PbootCMS 常用 if 判断
下一条:Pbcms 使用 Ajax 无刷新提交留言及表单
相关导航
pbootcms列表序号从···
我们需要给文章列表显示一个···
pbootcms修改默认t···
pbootcms默认的模板···
pbootcms修改默认首···
pbootcms默认的首页···
Pbcms Ajax 无刷···
Ajax 无刷新加载内容,···
Pbcms 使用 Ajax···
PbootCMS 本身对于···
Pbootcms ajax···
先引入 jq 文件<···
PbootCMS 常用 i···
1. 导航高亮{pboot···
Copyright © 2018-2020 营蜂创意营销 All Rights Reserved.
您将离开本站并访问