elm = $(this); var cid = elm.data('cid'); $.post(ep, { cid: cid, rating: 1 }, function(rating) { elm.attr({ 'data-count': rating.count, 'data-average': rating.average }); }); }); })();