Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).on('click','a.fav-add',function(e){
- var o=$(this);
- var id=o.attr('alt');
- if(id){
- $.ajax({
- url: estate_folder + "/js/ajax.php?action=add_to_favorites",
- data: 'id='+id,
- type: "POST",
- dataType: "json",
- success: function(json){
- if(json.response.body=='OK'){
- var favcount=$('#favorites_count');
- if(favcount.length>0){
- favcount.text(new Number($('#favorites_count').text())+1);
- }
- o.removeClass('fav-add').addClass('fav-rem');
- }
- },
- error: function(xhr, ajaxOptions, thrownError){
- }
- });
- }
- e.preventDefaults();
- });
- $(document).on('click','a.fav-rem',function(e){
- var o=$(this);
- var id=o.attr('alt');
- if(id){
- $.ajax({
- url: estate_folder + "/js/ajax.php?action=remove_from_favorites",
- data: 'id='+id,
- type: "POST",
- dataType: "json",
- success: function(json){
- if(json.response.body=='OK'){
- var favcount=$('#favorites_count');
- if(favcount.length>0){
- favcount.text(new Number($('#favorites_count').text())-1);
- }
- o.removeClass('fav-rem').addClass('fav-add');
- }
- },
- error: function(xhr, ajaxOptions, thrownError){
- }
- });
- }
- e.preventDefaults();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement