.
Pbootcms ajax 无刷新点赞
2024-04-08
11
先引入 jq 文件
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
无须使用 API,
把以下代码放入合适的位置即可,可自定义 css| 01 | <button class="support">点赞</button> <!--按钮---> |
| 02 | <div id="support_number">{content:likes}</div> <!--赞数量--> |
| 03 | <p class="supported"></p> <!--已赞提示--> |
| 06 | $('.support').on('click', //绑定事件 |
| 09 | url: '{content:likeslink}', //点赞链接 |
| 13 | success: function(data) { |
| 14 | $('#support_number').load(location.href + " #support_number"); //点赞后刷新#support_number |
| 15 | if (data.state) {} else { |
| 16 | $(".supported").html("已点赞!") //已赞提示 |
| 18 | error: function(xhr, status, error) { |
|
免责声明:以上内容转自其它媒体,相关信息仅为传播更多信息,与本站立场无关。做网站,做小程序,模板小程序不保证该信息(包含但不限于文字、视频、音频、数据及图表)全部或者部分内容的准确性、真实性、完整性、有效性、及时性、原创性等,如有侵权请联系4000-277-886。