01
<button class=
"support"
>点赞</button> <!--按钮--->
02
<div
id
=
"support_number"
>{content:likes}</div> <!--赞数量-->
03
<p class=
"supported"
></p> <!--已赞提示-->
04
<!--ajax-->
05
<script>
06
$(
'.support'
).on(
'click'
, //绑定事件
07
function
() {
08
$.ajax({
09
url:
'{content:likeslink}'
, //点赞链接
10
data: {
11
'likes'
:
12
},
13
success:
(data) {
14
'#support_number'
).load(location.href +
" #support_number"
); //点赞后刷新#support_number
15
if
(data.state) {}
else
{
16
".supported"
).html(
"已点赞!"
) //已赞提示
17
}},
18
error:
(xhr, status, error) {
19
console.log(error)
20
}
21
});
22
})
23
</script>
皖公网安备 34010402701667号