New Landing How can we help? Themeforest Theme Support Supreme Love It button broke: sends a love but returns error

Viewing 3 posts - 1 through 3 (of 3 total)
  • Posted in: Supreme
  • #24284
    sobodash
    Member

    We’re having a problem with the Love It button on posts at our website.

    http://beijingtoday.com.cn/

    When visitors click Love, it adds +1 to the love count but returns an error message saying it failed.

    “Sorry, there was a problem processing your request.”

    After this they can still click “Love” and boost the count as much as they want.

    Any idea how we can track down and resolve this problem? Since it’s actually hitting the ajax script it doesn’t appear to be a plugin conflict.

    #24615
    laranz – SUPPORT
    Member
    Post count: 3186

    Hi,

    The ajax request is success but I don’t have a clue why this error message shows up. I will forward this to the developer for some insights.

    Thanks,
    laranz.

    #24952
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi there,

    Try changing /includes/plugins/love-it/js/love-it.js contents to the following. It seems as those your AJAX response has added spacing for some reason.

    
    jQuery(document).ready( function($) {	
    	$('.love-it').on('click', function() {
    		var $this = $(this);	
    		var post_id = $this.data('post-id');
    		var user_id = $this.data('user-id');
    		var data = {
    			action: 'love_it',
    			item_id: post_id,
    			user_id: user_id,
    			love_it_nonce: love_it_vars.nonce
    		};
    		
    		// don't allow the user to love the item more than once
    		if($this.hasClass('loved')) {
    			alert(love_it_vars.already_loved_message);
    			return false;
    		}	
    		if(love_it_vars.logged_in == 'false' && $.cookie('loved-' + post_id)) {
    			alert(love_it_vars.already_loved_message);
    			return false;
    		}
    		
    		$.post(love_it_vars.ajaxurl, data, function(response) {
    			var ajaxResponse = jQuery.trim(response);
    			if(ajaxResponse == 'loved') {
    				$this.addClass('loved');
    				var count_wrap = $this.next();
    				var count = count_wrap.text();
    				count_wrap.text(parseInt(count) + 1);
    				if(love_it_vars.logged_in == 'false') {
    					$.cookie('loved-' + post_id, 'yes', { expires: 1 });
    				}
    			} else {
    				alert(love_it_vars.error_message);
    			}
    		});
    		return false;
    	});	
    });
    

    – Ed

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register