-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathliker.ajax.js
28 lines (28 loc) · 836 Bytes
/
liker.ajax.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
jQuery(document).ready(function(){
jQuery('body').on('click','.idev-post-like',function(event)
{
event.preventDefault();
liker=jQuery(this);
post_id=liker.data("post_id");
liker.html("<i id='icon-like' class='icon-like'></i><i id='icon-gear' class='icon-gear'></i>");
jQuery.ajax({
type:"post",url:ajax_var.url,
data:"action=idev-post-like&nonce="+ajax_var.nonce+"&idev_post_like=&post_id="+post_id,
success:function(count){
if(count.indexOf("count")!==-1){
var lecount=count.replace("count","");
if(lecount==="0"){
lecount="likes"
}
liker.prop('title','Like');
liker.removeClass("liked");
liker.html(" "+lecount)
}else{
liker.prop('title','liked');
liker.addClass("liked");
liker.html(" "+count)
}
}
})
}
)});