$(document).on('click', 'a.reaction[title]', function(e) { var that = this; var reaction = $(that).attr('title') ? $(that).attr('title') : $(that).attr('data-original-title'); if (rrDebug) console.log(reaction); if (reaction) { var message = $(that).parents('.reactions'); if (message && message.length > 0) { // expand when reaction is more reactions if (reaction.startsWith("More")) $(message).addClass('showall'); else { var id = elId = $(message[0]).attr('id'); if (id && id.indexOf('_') > 0) id = id.substr(id.indexOf('_') + 1); var fdata = new FormData(); fdata.append('target', 'react'); fdata.append('reaction', reaction); fdata.append('message', id); $.ajax({ type: 'POST', url: '/handlers/SocialHandler.ashx', crossDomain: true, xhrFields: { withCredentials: true }, contentType: false, processData: false, data: fdata, success: function(e) { var response = JSON.parse(e); if (response.success && response.reactions) { // review all of the reactions $('#' + elId).find('a.reaction[title]').each(function(i, r) { var react = null; $.each(response.reactions, function(i1, r1) { if (r1.name.toLowerCase() == ($(r).attr('title') ? $(r).attr('title') : $(r).attr('data-original-title')).toLowerCase()){ react = r1; return false; } }); //var react = response.reactions.find(r1 => ) if (react) { $(r).find('span[total]').attr('total', react.count).text(react.count); $(r).attr('data-content', react.reacters); //$(that).find('span[total]').attr('total', response.count).text(response.count); } }); } else { console.log('an error occurred liking something'); /*else { $('.toast').each(function(e, it) { $(it).text('failed'); MakeToast(); $(it).fadeIn(); EatToast(); }); }*/ } }}); } } } });